@zlooks.cn/password-auth-server 1.0.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.
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-browser/chunks/chunk-Q3WJINFG.js +48386 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-browser/src-plugin-page-frame-07c4de56a6-3F24AYCH.css +170 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-browser/src-plugin-page-frame-07c4de56a6-OCDODDFY.js +440 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-browser/src-plugin-password-form-3bd63d69e5-CCNUYY62.js +706 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-browser/src-plugin-password-form-3bd63d69e5-TRYMJX4F.css +195 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-ssr/chunks/chunk-36DACA7C.js +155814 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-ssr/src-plugin-page-frame-07c4de56a6-SYE4RRNX.js +441 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/client-ssr/src-plugin-password-form-3bd63d69e5-YVCPJXLL.js +708 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/plugin.json +90 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/server-rsc/index.js +15298 -0
- package/.hile-rsc/build-mtie8wg2-ca38f847/styles/4b3193c4f2b317ffed425ccf401342a4bdd6ccfd5f9c42def3315e776f166975.css +385 -0
- package/dist/command/index.d.ts +3 -0
- package/dist/command/index.d.ts.map +1 -0
- package/dist/command/index.js +24 -0
- package/dist/command/index.js.map +1 -0
- package/dist/config/schema.d.ts +72 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +48 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/email/nodemailer-verification-email-sender.d.ts +11 -0
- package/dist/email/nodemailer-verification-email-sender.d.ts.map +1 -0
- package/dist/email/nodemailer-verification-email-sender.js +54 -0
- package/dist/email/nodemailer-verification-email-sender.js.map +1 -0
- package/dist/email/verification-code-rate-limiter.d.ts +14 -0
- package/dist/email/verification-code-rate-limiter.d.ts.map +1 -0
- package/dist/email/verification-code-rate-limiter.js +27 -0
- package/dist/email/verification-code-rate-limiter.js.map +1 -0
- package/dist/email/verification-email-sender.d.ts +10 -0
- package/dist/email/verification-email-sender.d.ts.map +1 -0
- package/dist/email/verification-email-sender.js +2 -0
- package/dist/email/verification-email-sender.js.map +1 -0
- package/dist/messages/auth-extension/begin.msg.d.ts +3 -0
- package/dist/messages/auth-extension/begin.msg.d.ts.map +1 -0
- package/dist/messages/auth-extension/begin.msg.js +8 -0
- package/dist/messages/auth-extension/begin.msg.js.map +1 -0
- package/dist/messages/auth-extension/complete.msg.d.ts +3 -0
- package/dist/messages/auth-extension/complete.msg.d.ts.map +1 -0
- package/dist/messages/auth-extension/complete.msg.js +8 -0
- package/dist/messages/auth-extension/complete.msg.js.map +1 -0
- package/dist/migrations/index.d.ts +3 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +2 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/password/attempt-coordinator.d.ts +12 -0
- package/dist/password/attempt-coordinator.d.ts.map +1 -0
- package/dist/password/attempt-coordinator.js +25 -0
- package/dist/password/attempt-coordinator.js.map +1 -0
- package/dist/password/credential-lifecycle-outbox.d.ts +42 -0
- package/dist/password/credential-lifecycle-outbox.d.ts.map +1 -0
- package/dist/password/credential-lifecycle-outbox.js +119 -0
- package/dist/password/credential-lifecycle-outbox.js.map +1 -0
- package/dist/password/credential-repository.d.ts +41 -0
- package/dist/password/credential-repository.d.ts.map +1 -0
- package/dist/password/credential-repository.js +64 -0
- package/dist/password/credential-repository.js.map +1 -0
- package/dist/password/password-authenticator.d.ts +59 -0
- package/dist/password/password-authenticator.d.ts.map +1 -0
- package/dist/password/password-authenticator.js +184 -0
- package/dist/password/password-authenticator.js.map +1 -0
- package/dist/password/typeorm-credential-repository.d.ts +15 -0
- package/dist/password/typeorm-credential-repository.d.ts.map +1 -0
- package/dist/password/typeorm-credential-repository.js +125 -0
- package/dist/password/typeorm-credential-repository.js.map +1 -0
- package/dist/persistence/entities.d.ts +29 -0
- package/dist/persistence/entities.d.ts.map +1 -0
- package/dist/persistence/entities.js +49 -0
- package/dist/persistence/entities.js.map +1 -0
- package/dist/runtime/auth-announcement-publisher.d.ts +18 -0
- package/dist/runtime/auth-announcement-publisher.d.ts.map +1 -0
- package/dist/runtime/auth-announcement-publisher.js +106 -0
- package/dist/runtime/auth-announcement-publisher.js.map +1 -0
- package/dist/runtime/password-auth-runtime.d.ts +33 -0
- package/dist/runtime/password-auth-runtime.d.ts.map +1 -0
- package/dist/runtime/password-auth-runtime.js +218 -0
- package/dist/runtime/password-auth-runtime.js.map +1 -0
- package/dist/runtime/password-state-store.d.ts +49 -0
- package/dist/runtime/password-state-store.d.ts.map +1 -0
- package/dist/runtime/password-state-store.js +130 -0
- package/dist/runtime/password-state-store.js.map +1 -0
- package/dist/service-identity.d.ts +2 -0
- package/dist/service-identity.d.ts.map +1 -0
- package/dist/service-identity.js +2 -0
- package/dist/service-identity.js.map +1 -0
- package/dist/services/application.service.d.ts +8 -0
- package/dist/services/application.service.d.ts.map +1 -0
- package/dist/services/application.service.js +22 -0
- package/dist/services/application.service.js.map +1 -0
- package/dist/services/config.service.d.ts +63 -0
- package/dist/services/config.service.d.ts.map +1 -0
- package/dist/services/config.service.js +20 -0
- package/dist/services/config.service.js.map +1 -0
- package/dist/services/database.service.d.ts +3 -0
- package/dist/services/database.service.d.ts.map +1 -0
- package/dist/services/database.service.js +23 -0
- package/dist/services/database.service.js.map +1 -0
- package/dist/services/email.service.d.ts +4 -0
- package/dist/services/email.service.d.ts.map +1 -0
- package/dist/services/email.service.js +37 -0
- package/dist/services/email.service.js.map +1 -0
- package/dist/services/logger.service.d.ts +4 -0
- package/dist/services/logger.service.d.ts.map +1 -0
- package/dist/services/logger.service.js +8 -0
- package/dist/services/logger.service.js.map +1 -0
- package/dist/services/password-auth.boot.d.ts +3 -0
- package/dist/services/password-auth.boot.d.ts.map +1 -0
- package/dist/services/password-auth.boot.js +4 -0
- package/dist/services/password-auth.boot.js.map +1 -0
- package/dist/services/password-runtime.service.d.ts +4 -0
- package/dist/services/password-runtime.service.d.ts.map +1 -0
- package/dist/services/password-runtime.service.js +135 -0
- package/dist/services/password-runtime.service.js.map +1 -0
- package/dist/services/redis.service.d.ts +4 -0
- package/dist/services/redis.service.d.ts.map +1 -0
- package/dist/services/redis.service.js +18 -0
- package/dist/services/redis.service.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
RscLink,
|
|
4
|
+
USER_SESSION_COOKIE,
|
|
5
|
+
app_default,
|
|
6
|
+
browserApiDispatchResponseSchema,
|
|
7
|
+
browserApiResponseSchema,
|
|
8
|
+
button_default,
|
|
9
|
+
external_exports,
|
|
10
|
+
form_default,
|
|
11
|
+
input_default,
|
|
12
|
+
isBrowserApiFailure,
|
|
13
|
+
jsx,
|
|
14
|
+
jsxs,
|
|
15
|
+
segmented_default,
|
|
16
|
+
useEffect,
|
|
17
|
+
useRef,
|
|
18
|
+
useRequest,
|
|
19
|
+
useRscNavigation,
|
|
20
|
+
useState
|
|
21
|
+
} from "./chunks/chunk-Q3WJINFG.js";
|
|
22
|
+
|
|
23
|
+
// ../user-shared/dist/identity.js
|
|
24
|
+
var USER_SERVICE_NAMESPACE = "cn.zlooks.user.server";
|
|
25
|
+
|
|
26
|
+
// ../user-shared/dist/events/snapshots.js
|
|
27
|
+
var userSessionRevocationReasonSchema = external_exports.enum([
|
|
28
|
+
"logout",
|
|
29
|
+
"user-request",
|
|
30
|
+
"family-limit",
|
|
31
|
+
"credential-recovery"
|
|
32
|
+
]);
|
|
33
|
+
var displayNameSchema = external_exports.string().refine((value) => value === value.trim().normalize("NFKC"), "Display name must be normalized").refine((value) => Array.from(value).length >= 1 && Array.from(value).length <= 160, "Display name must contain 1 to 160 Unicode code points");
|
|
34
|
+
var bioSchema = external_exports.string().refine((value) => value === value.trim().normalize("NFKC"), "Bio must be normalized").refine((value) => Array.from(value).length >= 1 && Array.from(value).length <= 500, "Bio must contain 1 to 500 Unicode code points");
|
|
35
|
+
var httpUrlSchema = external_exports.url().max(2048).refine((value) => {
|
|
36
|
+
const protocol = new URL(value).protocol;
|
|
37
|
+
return protocol === "http:" || protocol === "https:";
|
|
38
|
+
}, "URL must use HTTP or HTTPS").refine((value) => value === new URL(value).toString(), "URL must be canonical");
|
|
39
|
+
var emailSchema = external_exports.email().max(320).refine((value) => value === value.toLocaleLowerCase("en-US"), "Email must be lowercase");
|
|
40
|
+
var userEventSnapshotSchema = external_exports.strictObject({
|
|
41
|
+
id: external_exports.uuid(),
|
|
42
|
+
displayName: displayNameSchema.nullable(),
|
|
43
|
+
avatar: httpUrlSchema.nullable(),
|
|
44
|
+
homepage: httpUrlSchema.nullable(),
|
|
45
|
+
bio: bioSchema.nullable(),
|
|
46
|
+
email: emailSchema.nullable(),
|
|
47
|
+
emailVerified: external_exports.boolean(),
|
|
48
|
+
status: external_exports.enum(["active", "disabled", "deleted"]),
|
|
49
|
+
createdAt: external_exports.iso.datetime({ offset: true }),
|
|
50
|
+
updatedAt: external_exports.iso.datetime({ offset: true }),
|
|
51
|
+
version: external_exports.number().int().positive()
|
|
52
|
+
}).superRefine((user, context) => {
|
|
53
|
+
if (user.emailVerified && user.email === null) {
|
|
54
|
+
context.addIssue({
|
|
55
|
+
code: "custom",
|
|
56
|
+
message: "A verified user snapshot must include its email",
|
|
57
|
+
path: ["email"]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (Date.parse(user.updatedAt) < Date.parse(user.createdAt)) {
|
|
61
|
+
context.addIssue({
|
|
62
|
+
code: "custom",
|
|
63
|
+
message: "User updated time must not precede creation time",
|
|
64
|
+
path: ["updatedAt"]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}).readonly();
|
|
68
|
+
var userSessionFamilyEventSnapshotSchema = external_exports.strictObject({
|
|
69
|
+
id: external_exports.uuid(),
|
|
70
|
+
userId: external_exports.uuid(),
|
|
71
|
+
createdAt: external_exports.iso.datetime({ offset: true }),
|
|
72
|
+
expiresAt: external_exports.iso.datetime({ offset: true }),
|
|
73
|
+
lastSeenAt: external_exports.iso.datetime({ offset: true }),
|
|
74
|
+
revokedAt: external_exports.iso.datetime({ offset: true }).nullable(),
|
|
75
|
+
revokeReason: userSessionRevocationReasonSchema.nullable()
|
|
76
|
+
}).superRefine((session, context) => {
|
|
77
|
+
const createdAt = Date.parse(session.createdAt);
|
|
78
|
+
if (session.revokedAt === null !== (session.revokeReason === null)) {
|
|
79
|
+
context.addIssue({
|
|
80
|
+
code: "custom",
|
|
81
|
+
message: "Session revocation time and reason must be present together",
|
|
82
|
+
path: ["revokedAt"]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (Date.parse(session.expiresAt) <= createdAt) {
|
|
86
|
+
context.addIssue({
|
|
87
|
+
code: "custom",
|
|
88
|
+
message: "Session expiry must follow creation time",
|
|
89
|
+
path: ["expiresAt"]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const lastSeenAt = Date.parse(session.lastSeenAt);
|
|
93
|
+
if (lastSeenAt < createdAt || lastSeenAt > Date.parse(session.expiresAt)) {
|
|
94
|
+
context.addIssue({
|
|
95
|
+
code: "custom",
|
|
96
|
+
message: "Session last-seen time must fall within its lifetime",
|
|
97
|
+
path: ["lastSeenAt"]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (session.revokedAt !== null && Date.parse(session.revokedAt) < createdAt) {
|
|
101
|
+
context.addIssue({
|
|
102
|
+
code: "custom",
|
|
103
|
+
message: "Session revoked time must not precede creation time",
|
|
104
|
+
path: ["revokedAt"]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}).readonly();
|
|
108
|
+
|
|
109
|
+
// ../event-bus/dist/index.js
|
|
110
|
+
var eventType = external_exports.string().max(256).regex(/^[a-z][a-z0-9]*(?:\.[a-z][a-z0-9-]*)+\.v[1-9][0-9]*$/);
|
|
111
|
+
var serviceNamespace = external_exports.string().max(256).regex(/^[a-z][a-z0-9]*(?:\.[a-z][a-z0-9]*)+$/);
|
|
112
|
+
var aggregateType = external_exports.string().regex(/^[a-z][a-z0-9-]{0,63}$/);
|
|
113
|
+
var aggregateId = external_exports.string().trim().min(1).max(256);
|
|
114
|
+
var eventEnvelopeSchema = external_exports.strictObject({
|
|
115
|
+
protocol: external_exports.literal("zlooks.event"),
|
|
116
|
+
protocolVersion: external_exports.literal(1),
|
|
117
|
+
eventId: external_exports.uuid(),
|
|
118
|
+
type: eventType,
|
|
119
|
+
producer: serviceNamespace,
|
|
120
|
+
aggregate: external_exports.strictObject({
|
|
121
|
+
type: aggregateType,
|
|
122
|
+
id: aggregateId
|
|
123
|
+
}).readonly(),
|
|
124
|
+
occurredAt: external_exports.iso.datetime({ offset: true }),
|
|
125
|
+
data: external_exports.unknown()
|
|
126
|
+
}).readonly();
|
|
127
|
+
function defineEvent(type, dataSchema5) {
|
|
128
|
+
const parsedType = eventType.parse(type);
|
|
129
|
+
return Object.freeze({
|
|
130
|
+
type: parsedType,
|
|
131
|
+
parse(value) {
|
|
132
|
+
const envelope = eventEnvelopeSchema.parse(value);
|
|
133
|
+
if (envelope.type !== parsedType) {
|
|
134
|
+
throw new TypeError(`Expected event type ${parsedType}`);
|
|
135
|
+
}
|
|
136
|
+
return Object.freeze({
|
|
137
|
+
...envelope,
|
|
138
|
+
type: parsedType,
|
|
139
|
+
aggregate: Object.freeze({ ...envelope.aggregate }),
|
|
140
|
+
data: dataSchema5.parse(envelope.data)
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ../user-shared/dist/events/definition.js
|
|
147
|
+
function defineUserEvent(type, aggregateType2, dataSchema5, aggregateId2) {
|
|
148
|
+
const base = defineEvent(type, dataSchema5);
|
|
149
|
+
return Object.freeze({
|
|
150
|
+
type: base.type,
|
|
151
|
+
parse(input) {
|
|
152
|
+
const event = base.parse(input);
|
|
153
|
+
if (event.producer !== USER_SERVICE_NAMESPACE) {
|
|
154
|
+
throw new TypeError(`Expected event producer ${USER_SERVICE_NAMESPACE}`);
|
|
155
|
+
}
|
|
156
|
+
if (event.aggregate.type !== aggregateType2 || event.aggregate.id !== aggregateId2(event.data)) {
|
|
157
|
+
throw new TypeError(`${type} aggregate does not identify its event data`);
|
|
158
|
+
}
|
|
159
|
+
return event;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ../user-shared/dist/events/user-registered.js
|
|
165
|
+
var USER_REGISTERED_EVENT_TYPE = "cn.zlooks.user.registered.v1";
|
|
166
|
+
var userRegisteredDataSchema = external_exports.strictObject({
|
|
167
|
+
user: userEventSnapshotSchema
|
|
168
|
+
}).refine((data) => data.user.status === "active", {
|
|
169
|
+
message: "A registered user snapshot must be active",
|
|
170
|
+
path: ["user", "status"]
|
|
171
|
+
}).readonly();
|
|
172
|
+
var userRegisteredEvent = defineUserEvent(USER_REGISTERED_EVENT_TYPE, "user", userRegisteredDataSchema, (data) => data.user.id);
|
|
173
|
+
|
|
174
|
+
// ../user-shared/dist/events/user-email-verified.js
|
|
175
|
+
var USER_EMAIL_VERIFIED_EVENT_TYPE = "cn.zlooks.user.email-verified.v1";
|
|
176
|
+
var dataSchema = external_exports.strictObject({ user: userEventSnapshotSchema }).refine((data) => data.user.email !== null && data.user.emailVerified, {
|
|
177
|
+
message: "An email-verified event must contain a verified email snapshot",
|
|
178
|
+
path: ["user", "emailVerified"]
|
|
179
|
+
}).readonly();
|
|
180
|
+
var userEmailVerifiedEvent = defineUserEvent(USER_EMAIL_VERIFIED_EVENT_TYPE, "user", dataSchema, (data) => data.user.id);
|
|
181
|
+
|
|
182
|
+
// ../user-shared/dist/events/user-profile-updated.js
|
|
183
|
+
var USER_PROFILE_UPDATED_EVENT_TYPE = "cn.zlooks.user.profile-updated.v1";
|
|
184
|
+
var userProfileFieldSchema = external_exports.enum(["displayName", "avatar", "homepage", "bio"]);
|
|
185
|
+
var dataSchema2 = external_exports.strictObject({
|
|
186
|
+
user: userEventSnapshotSchema,
|
|
187
|
+
changedFields: external_exports.array(userProfileFieldSchema).min(1).max(4).refine((fields) => new Set(fields).size === fields.length, "Profile fields must be unique").readonly()
|
|
188
|
+
}).readonly();
|
|
189
|
+
var userProfileUpdatedEvent = defineUserEvent(USER_PROFILE_UPDATED_EVENT_TYPE, "user", dataSchema2, (data) => data.user.id);
|
|
190
|
+
|
|
191
|
+
// ../user-shared/dist/events/user-session-created.js
|
|
192
|
+
var USER_SESSION_CREATED_EVENT_TYPE = "cn.zlooks.user.session-created.v1";
|
|
193
|
+
var dataSchema3 = external_exports.strictObject({
|
|
194
|
+
user: userEventSnapshotSchema,
|
|
195
|
+
sessionFamily: userSessionFamilyEventSnapshotSchema,
|
|
196
|
+
intent: external_exports.enum(["login", "registration", "recovery"])
|
|
197
|
+
}).superRefine((data, context) => {
|
|
198
|
+
if (data.sessionFamily.userId !== data.user.id) {
|
|
199
|
+
context.addIssue({
|
|
200
|
+
code: "custom",
|
|
201
|
+
message: "Session and user snapshots must identify the same user",
|
|
202
|
+
path: ["sessionFamily", "userId"]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (data.sessionFamily.revokedAt !== null) {
|
|
206
|
+
context.addIssue({
|
|
207
|
+
code: "custom",
|
|
208
|
+
message: "A created session snapshot must be active",
|
|
209
|
+
path: ["sessionFamily", "revokedAt"]
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (data.user.status !== "active") {
|
|
213
|
+
context.addIssue({
|
|
214
|
+
code: "custom",
|
|
215
|
+
message: "A session-created event must contain an active user snapshot",
|
|
216
|
+
path: ["user", "status"]
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}).readonly();
|
|
220
|
+
var userSessionCreatedEvent = defineUserEvent(USER_SESSION_CREATED_EVENT_TYPE, "session-family", dataSchema3, (data) => data.sessionFamily.id);
|
|
221
|
+
|
|
222
|
+
// ../user-shared/dist/events/user-session-revoked.js
|
|
223
|
+
var USER_SESSION_REVOKED_EVENT_TYPE = "cn.zlooks.user.session-revoked.v1";
|
|
224
|
+
var dataSchema4 = external_exports.strictObject({
|
|
225
|
+
user: userEventSnapshotSchema,
|
|
226
|
+
sessionFamily: userSessionFamilyEventSnapshotSchema
|
|
227
|
+
}).superRefine((data, context) => {
|
|
228
|
+
if (data.sessionFamily.userId !== data.user.id) {
|
|
229
|
+
context.addIssue({
|
|
230
|
+
code: "custom",
|
|
231
|
+
message: "Session and user snapshots must identify the same user",
|
|
232
|
+
path: ["sessionFamily", "userId"]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (data.sessionFamily.revokedAt === null) {
|
|
236
|
+
context.addIssue({
|
|
237
|
+
code: "custom",
|
|
238
|
+
message: "A revoked session snapshot must include its revocation",
|
|
239
|
+
path: ["sessionFamily", "revokedAt"]
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}).readonly();
|
|
243
|
+
var userSessionRevokedEvent = defineUserEvent(USER_SESSION_REVOKED_EVENT_TYPE, "session-family", dataSchema4, (data) => data.sessionFamily.id);
|
|
244
|
+
|
|
245
|
+
// ../user-shared/dist/index.js
|
|
246
|
+
var USER_BROWSER_API_PUBLIC_ROUTES = Object.freeze([
|
|
247
|
+
Object.freeze({
|
|
248
|
+
exact: "/api/auth/methods",
|
|
249
|
+
methods: Object.freeze(["GET"]),
|
|
250
|
+
forwardCookieNames: Object.freeze([])
|
|
251
|
+
}),
|
|
252
|
+
Object.freeze({
|
|
253
|
+
exact: "/api/user/shell",
|
|
254
|
+
methods: Object.freeze(["GET"]),
|
|
255
|
+
forwardCookieNames: Object.freeze([USER_SESSION_COOKIE])
|
|
256
|
+
}),
|
|
257
|
+
Object.freeze({
|
|
258
|
+
exact: "/api/user",
|
|
259
|
+
methods: Object.freeze(["GET", "PATCH"]),
|
|
260
|
+
forwardCookieNames: Object.freeze([USER_SESSION_COOKIE])
|
|
261
|
+
}),
|
|
262
|
+
Object.freeze({
|
|
263
|
+
exact: "/api/user/sessions",
|
|
264
|
+
methods: Object.freeze(["GET"]),
|
|
265
|
+
forwardCookieNames: Object.freeze([USER_SESSION_COOKIE])
|
|
266
|
+
}),
|
|
267
|
+
Object.freeze({
|
|
268
|
+
exact: "/api/auth/transactions",
|
|
269
|
+
methods: Object.freeze(["POST"]),
|
|
270
|
+
forwardCookieNames: Object.freeze([])
|
|
271
|
+
}),
|
|
272
|
+
Object.freeze({
|
|
273
|
+
prefix: "/api/auth/transactions/",
|
|
274
|
+
methods: Object.freeze(["POST"]),
|
|
275
|
+
forwardCookieNames: Object.freeze([])
|
|
276
|
+
}),
|
|
277
|
+
Object.freeze({
|
|
278
|
+
exact: "/api/auth/logout",
|
|
279
|
+
methods: Object.freeze(["POST"]),
|
|
280
|
+
forwardCookieNames: Object.freeze([USER_SESSION_COOKIE])
|
|
281
|
+
}),
|
|
282
|
+
Object.freeze({
|
|
283
|
+
exact: "/api/auth/session/refresh",
|
|
284
|
+
methods: Object.freeze(["POST"]),
|
|
285
|
+
forwardCookieNames: Object.freeze([USER_SESSION_COOKIE])
|
|
286
|
+
}),
|
|
287
|
+
Object.freeze({
|
|
288
|
+
prefix: "/api/user/sessions/",
|
|
289
|
+
methods: Object.freeze(["POST"]),
|
|
290
|
+
forwardCookieNames: Object.freeze([USER_SESSION_COOKIE])
|
|
291
|
+
})
|
|
292
|
+
]);
|
|
293
|
+
var USER_ACCOUNT_HREF = "/user.account/account";
|
|
294
|
+
var USER_BROWSER_API_ERROR_CODES = Object.freeze({
|
|
295
|
+
crossOriginRejected: 1001,
|
|
296
|
+
requestRejected: 1002,
|
|
297
|
+
authenticationRequired: 1003,
|
|
298
|
+
sessionExpired: 1004,
|
|
299
|
+
authenticationDenied: 1005,
|
|
300
|
+
authenticationPending: 1006,
|
|
301
|
+
routeNotFound: 1007,
|
|
302
|
+
accountNotFound: 1008,
|
|
303
|
+
accountAlreadyExists: 1009,
|
|
304
|
+
invalidVerificationCode: 1010,
|
|
305
|
+
verificationRateLimited: 1011,
|
|
306
|
+
emailDeliveryFailed: 1012,
|
|
307
|
+
serviceUnavailable: 1013
|
|
308
|
+
});
|
|
309
|
+
var absolutePath = external_exports.string().min(1).max(2048).regex(/^\/(?!\/)[^?#]*$/);
|
|
310
|
+
var userShellViewSchema = external_exports.discriminatedUnion("status", [
|
|
311
|
+
external_exports.strictObject({
|
|
312
|
+
status: external_exports.literal("anonymous"),
|
|
313
|
+
loginMethods: external_exports.array(external_exports.strictObject({
|
|
314
|
+
id: external_exports.string().min(1).max(128),
|
|
315
|
+
label: external_exports.string().min(1).max(80),
|
|
316
|
+
href: absolutePath
|
|
317
|
+
})).max(64)
|
|
318
|
+
}),
|
|
319
|
+
external_exports.strictObject({
|
|
320
|
+
status: external_exports.literal("authenticated"),
|
|
321
|
+
user: external_exports.strictObject({
|
|
322
|
+
label: external_exports.string().min(1).max(160),
|
|
323
|
+
secondary: external_exports.string().min(1).max(320).optional(),
|
|
324
|
+
avatarText: external_exports.string().min(1).max(8),
|
|
325
|
+
avatarUrl: external_exports.url({ protocol: /^https?$/ }).max(2048).optional()
|
|
326
|
+
}),
|
|
327
|
+
accountHref: absolutePath,
|
|
328
|
+
logoutHref: absolutePath
|
|
329
|
+
})
|
|
330
|
+
]).readonly();
|
|
331
|
+
var sessionCookieSchema = external_exports.discriminatedUnion("action", [
|
|
332
|
+
external_exports.strictObject({
|
|
333
|
+
action: external_exports.literal("set"),
|
|
334
|
+
value: external_exports.string().min(1).max(4096),
|
|
335
|
+
expiresAt: external_exports.iso.datetime({ offset: true })
|
|
336
|
+
}),
|
|
337
|
+
external_exports.strictObject({ action: external_exports.literal("clear") })
|
|
338
|
+
]);
|
|
339
|
+
var userCurrentUserRequestSchema = external_exports.strictObject({}).readonly();
|
|
340
|
+
var userPublicProfileSchema = external_exports.strictObject({
|
|
341
|
+
id: external_exports.uuid(),
|
|
342
|
+
displayName: external_exports.string().trim().min(1).max(160).nullable(),
|
|
343
|
+
avatar: external_exports.url({ protocol: /^https?$/ }).max(2048).nullable(),
|
|
344
|
+
homepage: external_exports.url({ protocol: /^https?$/ }).max(2048).nullable().optional(),
|
|
345
|
+
bio: external_exports.string().trim().min(1).max(500).nullable().optional()
|
|
346
|
+
}).readonly();
|
|
347
|
+
var userCurrentUserSchema = userPublicProfileSchema;
|
|
348
|
+
var userCurrentUserResponseSchema = external_exports.discriminatedUnion("authenticated", [
|
|
349
|
+
external_exports.strictObject({ authenticated: external_exports.literal(false) }),
|
|
350
|
+
external_exports.strictObject({
|
|
351
|
+
authenticated: external_exports.literal(true),
|
|
352
|
+
user: userCurrentUserSchema
|
|
353
|
+
})
|
|
354
|
+
]).readonly();
|
|
355
|
+
var userPublicProfilesRequestSchema = external_exports.strictObject({
|
|
356
|
+
userIds: external_exports.array(external_exports.uuid()).min(1).max(100).refine((userIds) => new Set(userIds).size === userIds.length, { message: "User IDs must be unique" }).readonly()
|
|
357
|
+
}).readonly();
|
|
358
|
+
var userPublicProfilesResponseSchema = external_exports.strictObject({
|
|
359
|
+
users: external_exports.array(userPublicProfileSchema).max(100).refine((users) => new Set(users.map((user) => user.id)).size === users.length, { message: "Public user profiles must be unique" }).readonly()
|
|
360
|
+
}).readonly();
|
|
361
|
+
var userBrowserApiRequestSchema = external_exports.strictObject({
|
|
362
|
+
method: external_exports.enum(["GET", "POST", "PATCH"]),
|
|
363
|
+
path: absolutePath,
|
|
364
|
+
origin: external_exports.string().max(2048).optional(),
|
|
365
|
+
clientKey: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
366
|
+
body: external_exports.unknown().optional()
|
|
367
|
+
}).readonly();
|
|
368
|
+
var userBrowserApiProviderRequestSchema = external_exports.strictObject({
|
|
369
|
+
method: external_exports.enum(["GET", "POST", "PATCH"]),
|
|
370
|
+
path: absolutePath,
|
|
371
|
+
origin: external_exports.string().max(2048).optional(),
|
|
372
|
+
clientKey: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
373
|
+
body: external_exports.unknown().optional()
|
|
374
|
+
}).readonly();
|
|
375
|
+
var userBrowserApiProviderResponseSchema = browserApiDispatchResponseSchema.superRefine((response, context) => {
|
|
376
|
+
for (const [index, effect] of (response.cookieEffects ?? []).entries()) {
|
|
377
|
+
if (effect.name === USER_SESSION_COOKIE)
|
|
378
|
+
continue;
|
|
379
|
+
context.addIssue({
|
|
380
|
+
code: "custom",
|
|
381
|
+
message: "User Browser API may only mutate its declared session cookie",
|
|
382
|
+
path: ["cookieEffects", index, "name"]
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}).readonly();
|
|
386
|
+
var userBrowserApiResponseSchema = external_exports.strictObject({
|
|
387
|
+
status: external_exports.number().int().min(200).max(599).refine((status) => status < 300 || status >= 400),
|
|
388
|
+
body: browserApiResponseSchema,
|
|
389
|
+
sessionCookie: sessionCookieSchema.optional()
|
|
390
|
+
}).superRefine((response, context) => {
|
|
391
|
+
const httpSucceeded = response.status >= 200 && response.status < 300;
|
|
392
|
+
if (httpSucceeded === !isBrowserApiFailure(response.body))
|
|
393
|
+
return;
|
|
394
|
+
context.addIssue({
|
|
395
|
+
code: "custom",
|
|
396
|
+
message: "HTTP status and browser API response code disagree",
|
|
397
|
+
path: ["body", "code"]
|
|
398
|
+
});
|
|
399
|
+
}).readonly();
|
|
400
|
+
var userCredentialLifecycleEventSchema = external_exports.strictObject({
|
|
401
|
+
protocol: external_exports.literal("zlooks.user.credential-lifecycle"),
|
|
402
|
+
kind: external_exports.enum(["registration", "recovery"]),
|
|
403
|
+
authenticationTransactionId: external_exports.uuid(),
|
|
404
|
+
extensionId: external_exports.string().regex(/^[a-z][a-z0-9._-]{0,127}$/),
|
|
405
|
+
methodId: external_exports.string().regex(/^[a-z][a-z0-9._-]{0,127}$/),
|
|
406
|
+
subject: external_exports.string().trim().min(1).max(512),
|
|
407
|
+
email: external_exports.email().max(320),
|
|
408
|
+
occurredAt: external_exports.iso.datetime({ offset: true })
|
|
409
|
+
}).readonly();
|
|
410
|
+
var userCredentialLifecycleResponseSchema = external_exports.strictObject({
|
|
411
|
+
acknowledged: external_exports.literal(true)
|
|
412
|
+
}).readonly();
|
|
413
|
+
|
|
414
|
+
// src/plugin/auth-response.ts
|
|
415
|
+
function parseAuthenticationCompletion(input) {
|
|
416
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
417
|
+
throw new Error("\u8BA4\u8BC1\u54CD\u5E94\u65E0\u6548");
|
|
418
|
+
}
|
|
419
|
+
const response = input;
|
|
420
|
+
if (response.status === "verified") return { status: "verified" };
|
|
421
|
+
if (response.status === "denied") throw new Error("\u8BA4\u8BC1\u4FE1\u606F\u65E0\u6548\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u8BD5");
|
|
422
|
+
if (response.status === "pending") throw new Error("\u8BA4\u8BC1\u4ECD\u5728\u5904\u7406\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
423
|
+
throw new Error("\u8BA4\u8BC1\u54CD\u5E94\u65E0\u6548");
|
|
424
|
+
}
|
|
425
|
+
function parseAuthenticationChallenge(input) {
|
|
426
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
427
|
+
throw new Error("\u9A8C\u8BC1\u7801\u54CD\u5E94\u65E0\u6548");
|
|
428
|
+
}
|
|
429
|
+
const response = input;
|
|
430
|
+
if (response.status !== "pending" || !Number.isSafeInteger(response.retryAfterMs) || response.retryAfterMs <= 0 || response.retryAfterMs > 6e4) {
|
|
431
|
+
throw new Error("\u9A8C\u8BC1\u7801\u54CD\u5E94\u65E0\u6548");
|
|
432
|
+
}
|
|
433
|
+
return { retryAfterMs: response.retryAfterMs };
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// src/plugin/password-form.module.css
|
|
437
|
+
var password_form_default = {
|
|
438
|
+
authShell: "password_form_authShell",
|
|
439
|
+
introduction: "password_form_introduction",
|
|
440
|
+
eyebrow: "password_form_eyebrow",
|
|
441
|
+
introductionTitle: "password_form_introductionTitle",
|
|
442
|
+
introductionCopy: "password_form_introductionCopy",
|
|
443
|
+
formRegion: "password_form_formRegion",
|
|
444
|
+
formBody: "password_form_formBody",
|
|
445
|
+
formNote: "password_form_formNote",
|
|
446
|
+
codeRow: "password_form_codeRow",
|
|
447
|
+
changeEmail: "password_form_changeEmail",
|
|
448
|
+
alternate: "password_form_alternate",
|
|
449
|
+
alternateLinks: "password_form_alternateLinks"
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
// src/plugin/password-form.tsx
|
|
453
|
+
function PasswordForm(props) {
|
|
454
|
+
const [form] = form_default.useForm();
|
|
455
|
+
const { message } = app_default.useApp();
|
|
456
|
+
const request = useRequest();
|
|
457
|
+
const navigation = useRscNavigation();
|
|
458
|
+
const [transactionId, setTransactionId] = useState(props.transactionId);
|
|
459
|
+
const [mode, setMode] = useState("password");
|
|
460
|
+
const [codeSent, setCodeSent] = useState(false);
|
|
461
|
+
const [countdown, setCountdown] = useState(0);
|
|
462
|
+
const [submitting, setSubmitting] = useState(false);
|
|
463
|
+
const [sending, setSending] = useState(false);
|
|
464
|
+
const pendingSend = useRef(void 0);
|
|
465
|
+
const usesCode = props.intent !== "login" || mode === "code";
|
|
466
|
+
const needsPassword = props.intent !== "login" || mode === "password";
|
|
467
|
+
useEffect(() => {
|
|
468
|
+
if (countdown <= 0) return;
|
|
469
|
+
const timer = window.setInterval(() => setCountdown((value) => Math.max(0, value - 1)), 1e3);
|
|
470
|
+
return () => window.clearInterval(timer);
|
|
471
|
+
}, [countdown > 0]);
|
|
472
|
+
async function ensureTransaction() {
|
|
473
|
+
if (transactionId) return transactionId;
|
|
474
|
+
const created = await beginTransaction(request, props.intent);
|
|
475
|
+
setTransactionId(created);
|
|
476
|
+
return created;
|
|
477
|
+
}
|
|
478
|
+
async function sendCode() {
|
|
479
|
+
try {
|
|
480
|
+
const { email } = await form.validateFields(["email"]);
|
|
481
|
+
setSending(true);
|
|
482
|
+
const currentTransactionId = await ensureTransaction();
|
|
483
|
+
const requestId = pendingSend.current?.email === email ? pendingSend.current.requestId : crypto.randomUUID();
|
|
484
|
+
pendingSend.current = { email, requestId };
|
|
485
|
+
const challenge = await request(
|
|
486
|
+
`/api/auth/transactions/${encodeURIComponent(currentTransactionId)}/complete`,
|
|
487
|
+
{
|
|
488
|
+
method: "POST",
|
|
489
|
+
headers: { "content-type": "application/json" },
|
|
490
|
+
credentials: "same-origin",
|
|
491
|
+
body: JSON.stringify({ input: { action: "send-code", email, requestId } })
|
|
492
|
+
},
|
|
493
|
+
{ errorMessage: "\u9A8C\u8BC1\u7801\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", parse: parseAuthenticationChallenge }
|
|
494
|
+
);
|
|
495
|
+
setCodeSent(true);
|
|
496
|
+
setCountdown(Math.ceil(challenge.retryAfterMs / 1e3));
|
|
497
|
+
pendingSend.current = void 0;
|
|
498
|
+
void message.success("\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001");
|
|
499
|
+
} catch {
|
|
500
|
+
} finally {
|
|
501
|
+
setSending(false);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
async function submit(values) {
|
|
505
|
+
setSubmitting(true);
|
|
506
|
+
try {
|
|
507
|
+
const currentTransactionId = await ensureTransaction();
|
|
508
|
+
const input = usesCode ? {
|
|
509
|
+
action: "verify-code",
|
|
510
|
+
email: values.email,
|
|
511
|
+
code: values.code,
|
|
512
|
+
...needsPassword ? { password: values.password } : {}
|
|
513
|
+
} : { action: "password-login", email: values.email, password: values.password };
|
|
514
|
+
await request(`/api/auth/transactions/${encodeURIComponent(currentTransactionId)}/complete`, {
|
|
515
|
+
method: "POST",
|
|
516
|
+
headers: { "content-type": "application/json" },
|
|
517
|
+
credentials: "same-origin",
|
|
518
|
+
body: JSON.stringify({ input })
|
|
519
|
+
}, { errorMessage: "\u6CA1\u6709\u5B8C\u6210\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165\u540E\u91CD\u8BD5", parse: parseAuthenticationCompletion });
|
|
520
|
+
if (props.intent === "registration") {
|
|
521
|
+
navigation.replace(USER_ACCOUNT_HREF);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
navigation.replace("/");
|
|
525
|
+
} catch {
|
|
526
|
+
} finally {
|
|
527
|
+
setSubmitting(false);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const copy = pageCopy(props.intent);
|
|
531
|
+
return /* @__PURE__ */ jsxs(
|
|
532
|
+
"section",
|
|
533
|
+
{
|
|
534
|
+
"aria-labelledby": "password-auth-title",
|
|
535
|
+
className: password_form_default.authShell,
|
|
536
|
+
"data-auth-method": "password",
|
|
537
|
+
"data-flat-auth-layout": true,
|
|
538
|
+
children: [
|
|
539
|
+
/* @__PURE__ */ jsxs("div", { className: password_form_default.introduction, children: [
|
|
540
|
+
/* @__PURE__ */ jsx("p", { className: password_form_default.eyebrow, children: copy.step }),
|
|
541
|
+
/* @__PURE__ */ jsx("h1", { className: password_form_default.introductionTitle, id: "password-auth-title", children: copy.title }),
|
|
542
|
+
/* @__PURE__ */ jsx("p", { className: password_form_default.introductionCopy, children: copy.introduction }),
|
|
543
|
+
/* @__PURE__ */ jsx(AlternateLinks, { intent: props.intent })
|
|
544
|
+
] }),
|
|
545
|
+
/* @__PURE__ */ jsxs("div", { className: password_form_default.formRegion, children: [
|
|
546
|
+
/* @__PURE__ */ jsx("div", { className: password_form_default.formBody, children: /* @__PURE__ */ jsxs(
|
|
547
|
+
form_default,
|
|
548
|
+
{
|
|
549
|
+
form,
|
|
550
|
+
layout: "vertical",
|
|
551
|
+
requiredMark: false,
|
|
552
|
+
scrollToFirstError: { focus: true },
|
|
553
|
+
validateTrigger: "onBlur",
|
|
554
|
+
onFinish: submit,
|
|
555
|
+
children: [
|
|
556
|
+
props.intent === "login" ? /* @__PURE__ */ jsx(form_default.Item, { children: /* @__PURE__ */ jsx(
|
|
557
|
+
segmented_default,
|
|
558
|
+
{
|
|
559
|
+
"aria-label": "\u9009\u62E9\u767B\u5F55\u65B9\u5F0F",
|
|
560
|
+
block: true,
|
|
561
|
+
options: [{ label: "\u5BC6\u7801\u767B\u5F55", value: "password" }, { label: "\u9A8C\u8BC1\u7801\u767B\u5F55", value: "code" }],
|
|
562
|
+
size: "large",
|
|
563
|
+
value: mode,
|
|
564
|
+
onChange: (value) => {
|
|
565
|
+
setMode(value);
|
|
566
|
+
setCodeSent(false);
|
|
567
|
+
setCountdown(0);
|
|
568
|
+
setTransactionId(props.transactionId);
|
|
569
|
+
pendingSend.current = void 0;
|
|
570
|
+
form.resetFields(["code"]);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
) }) : null,
|
|
574
|
+
/* @__PURE__ */ jsx(form_default.Item, { label: "\u90AE\u7BB1", name: "email", rules: emailRules, children: /* @__PURE__ */ jsx(input_default, { autoComplete: "username", disabled: codeSent, inputMode: "email", maxLength: 320, placeholder: "name@example.com", size: "large", type: "email" }) }),
|
|
575
|
+
codeSent ? /* @__PURE__ */ jsx(
|
|
576
|
+
button_default,
|
|
577
|
+
{
|
|
578
|
+
className: password_form_default.changeEmail,
|
|
579
|
+
disabled: sending || submitting,
|
|
580
|
+
type: "link",
|
|
581
|
+
onClick: () => {
|
|
582
|
+
setCodeSent(false);
|
|
583
|
+
setCountdown(0);
|
|
584
|
+
setTransactionId(void 0);
|
|
585
|
+
pendingSend.current = void 0;
|
|
586
|
+
form.resetFields(["code"]);
|
|
587
|
+
window.requestAnimationFrame(() => form.focusField("email"));
|
|
588
|
+
},
|
|
589
|
+
children: "\u4FEE\u6539\u90AE\u7BB1"
|
|
590
|
+
}
|
|
591
|
+
) : null,
|
|
592
|
+
usesCode ? /* @__PURE__ */ jsx(form_default.Item, { label: "\u9A8C\u8BC1\u7801", required: true, children: /* @__PURE__ */ jsxs("div", { className: password_form_default.codeRow, children: [
|
|
593
|
+
/* @__PURE__ */ jsx(form_default.Item, { noStyle: true, name: "code", rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801" }, { len: 6, message: "\u9A8C\u8BC1\u7801\u5E94\u4E3A 6 \u4F4D\u6570\u5B57" }, { pattern: /^\d{6}$/, message: "\u9A8C\u8BC1\u7801\u5E94\u4E3A 6 \u4F4D\u6570\u5B57" }], children: /* @__PURE__ */ jsx(input_default, { "aria-label": "\u9A8C\u8BC1\u7801", autoComplete: "one-time-code", inputMode: "numeric", maxLength: 6, placeholder: "6 \u4F4D\u9A8C\u8BC1\u7801", size: "large" }) }),
|
|
594
|
+
/* @__PURE__ */ jsx(button_default, { disabled: countdown > 0 || submitting, loading: sending, onClick: sendCode, size: "large", children: countdown > 0 ? `${countdown} \u79D2\u540E\u91CD\u53D1` : codeSent ? "\u91CD\u65B0\u53D1\u9001" : "\u53D1\u9001\u9A8C\u8BC1\u7801" })
|
|
595
|
+
] }) }) : null,
|
|
596
|
+
needsPassword ? /* @__PURE__ */ jsx(
|
|
597
|
+
form_default.Item,
|
|
598
|
+
{
|
|
599
|
+
extra: props.intent !== "login" ? "\u81F3\u5C11 12 \u4E2A\u5B57\u7B26\uFF0C\u5EFA\u8BAE\u4F7F\u7528\u5BC6\u7801\u7BA1\u7406\u5668\u751F\u6210\u5E76\u4FDD\u5B58\u3002" : void 0,
|
|
600
|
+
label: props.intent === "recovery" ? "\u65B0\u5BC6\u7801" : "\u5BC6\u7801",
|
|
601
|
+
name: "password",
|
|
602
|
+
rules: passwordRules(props.intent !== "login"),
|
|
603
|
+
children: /* @__PURE__ */ jsx(
|
|
604
|
+
input_default.Password,
|
|
605
|
+
{
|
|
606
|
+
autoComplete: props.intent === "login" ? "current-password" : "new-password",
|
|
607
|
+
maxLength: 128,
|
|
608
|
+
placeholder: props.intent === "login" ? "\u8F93\u5165\u5BC6\u7801" : "\u521B\u5EFA\u4E00\u4E2A\u5B89\u5168\u5BC6\u7801",
|
|
609
|
+
size: "large"
|
|
610
|
+
}
|
|
611
|
+
)
|
|
612
|
+
}
|
|
613
|
+
) : null,
|
|
614
|
+
/* @__PURE__ */ jsx(button_default, { block: true, htmlType: "submit", loading: submitting, size: "large", type: "primary", disabled: sending || usesCode && !codeSent, children: copy.submit })
|
|
615
|
+
]
|
|
616
|
+
}
|
|
617
|
+
) }),
|
|
618
|
+
/* @__PURE__ */ jsxs("aside", { className: password_form_default.formNote, children: [
|
|
619
|
+
/* @__PURE__ */ jsx("p", { children: copy.description }),
|
|
620
|
+
/* @__PURE__ */ jsx("span", { children: "\u4F60\u7684\u767B\u5F55\u4FE1\u606F\u53EA\u7528\u4E8E\u8BC6\u522B\u8D26\u6237\u3002" })
|
|
621
|
+
] })
|
|
622
|
+
] })
|
|
623
|
+
]
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
function AlternateLinks({ intent }) {
|
|
628
|
+
if (intent === "registration") return /* @__PURE__ */ jsxs("p", { className: password_form_default.alternate, children: [
|
|
629
|
+
"\u5DF2\u7ECF\u6709\u8D26\u53F7\uFF1F",
|
|
630
|
+
/* @__PURE__ */ jsx(RscLink, { href: "/auth.password/login", children: "\u8FD4\u56DE\u767B\u5F55" })
|
|
631
|
+
] });
|
|
632
|
+
if (intent === "recovery") return /* @__PURE__ */ jsxs("p", { className: password_form_default.alternate, children: [
|
|
633
|
+
"\u60F3\u8D77\u5BC6\u7801\u4E86\uFF1F",
|
|
634
|
+
/* @__PURE__ */ jsx(RscLink, { href: "/auth.password/login", children: "\u8FD4\u56DE\u767B\u5F55" })
|
|
635
|
+
] });
|
|
636
|
+
return /* @__PURE__ */ jsxs("div", { className: password_form_default.alternateLinks, children: [
|
|
637
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
638
|
+
/* @__PURE__ */ jsx("span", { children: "\u8FD8\u6CA1\u6709\u8D26\u6237\uFF1F" }),
|
|
639
|
+
/* @__PURE__ */ jsx(RscLink, { href: "/auth.password/register", children: "\u521B\u5EFA\u8D26\u6237" })
|
|
640
|
+
] }),
|
|
641
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
642
|
+
/* @__PURE__ */ jsx("span", { children: "\u5FD8\u8BB0\u5BC6\u7801\uFF1F" }),
|
|
643
|
+
/* @__PURE__ */ jsx(RscLink, { href: "/auth.password/recovery", children: "\u627E\u56DE\u5BC6\u7801" })
|
|
644
|
+
] })
|
|
645
|
+
] });
|
|
646
|
+
}
|
|
647
|
+
async function beginTransaction(request, intent) {
|
|
648
|
+
return request("/api/auth/transactions", {
|
|
649
|
+
method: "POST",
|
|
650
|
+
headers: { "content-type": "application/json" },
|
|
651
|
+
credentials: "same-origin",
|
|
652
|
+
body: JSON.stringify({ methodId: "password", intent })
|
|
653
|
+
}, { errorMessage: "\u6682\u65F6\u65E0\u6CD5\u7EE7\u7EED\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", parse: parseTransactionId });
|
|
654
|
+
}
|
|
655
|
+
function parseTransactionId(data) {
|
|
656
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) throw new Error("Invalid transaction response");
|
|
657
|
+
const transactionId = data.transactionId;
|
|
658
|
+
if (typeof transactionId !== "string" || !UUID.test(transactionId)) {
|
|
659
|
+
throw new Error("Invalid transaction response");
|
|
660
|
+
}
|
|
661
|
+
return transactionId;
|
|
662
|
+
}
|
|
663
|
+
var emailRules = [
|
|
664
|
+
{ required: true, message: "\u8BF7\u8F93\u5165\u90AE\u7BB1", whitespace: true },
|
|
665
|
+
{ type: "email", message: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1\u5730\u5740" },
|
|
666
|
+
{ max: 320, message: "\u90AE\u7BB1\u5730\u5740\u4E0D\u80FD\u8D85\u8FC7 320 \u4E2A\u5B57\u7B26" }
|
|
667
|
+
];
|
|
668
|
+
function passwordRules(requireMinimum) {
|
|
669
|
+
return [
|
|
670
|
+
{ required: true, message: "\u8BF7\u8F93\u5165\u5BC6\u7801" },
|
|
671
|
+
...requireMinimum ? [{
|
|
672
|
+
validator: async (_rule, value) => {
|
|
673
|
+
if (!value) return;
|
|
674
|
+
if (Array.from(value).length < 12) throw new Error("\u5BC6\u7801\u81F3\u5C11\u9700\u8981 12 \u4E2A\u5B57\u7B26");
|
|
675
|
+
if (new TextEncoder().encode(value).byteLength > 128) throw new Error("\u5BC6\u7801\u8FC7\u957F\uFF0C\u8BF7\u7F29\u77ED\u540E\u91CD\u8BD5");
|
|
676
|
+
}
|
|
677
|
+
}] : [{ max: 128, message: "\u5BC6\u7801\u4E0D\u80FD\u8D85\u8FC7 128 \u4E2A\u5B57\u7B26" }]
|
|
678
|
+
];
|
|
679
|
+
}
|
|
680
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
681
|
+
function pageCopy(intent) {
|
|
682
|
+
if (intent === "registration") return {
|
|
683
|
+
introduction: "\u9A8C\u8BC1\u90AE\u7BB1\u5E76\u521B\u5EFA\u8D26\u53F7\u540E\uFF0C\u53EF\u4EE5\u7EE7\u7EED\u5B8C\u5584\u8D44\u6599\uFF0C\u6574\u7406\u5C5E\u4E8E\u4F60\u7684\u8BB0\u5F55\u3002",
|
|
684
|
+
step: "ACCOUNT / REGISTER",
|
|
685
|
+
title: "\u521B\u5EFA\u8D26\u6237",
|
|
686
|
+
description: "\u4F7F\u7528\u90AE\u7BB1\u9A8C\u8BC1\u7801\u548C\u5BC6\u7801\u521B\u5EFA\u8D26\u53F7\u3002",
|
|
687
|
+
submit: "\u521B\u5EFA\u8D26\u53F7"
|
|
688
|
+
};
|
|
689
|
+
if (intent === "recovery") return {
|
|
690
|
+
introduction: "\u9A8C\u8BC1\u6CE8\u518C\u90AE\u7BB1\u540E\u8BBE\u7F6E\u65B0\u5BC6\u7801\uFF0C\u65E7\u8BBE\u5907\u4E0A\u7684\u767B\u5F55\u4F1A\u81EA\u52A8\u9000\u51FA\u3002",
|
|
691
|
+
step: "ACCOUNT / RECOVERY",
|
|
692
|
+
title: "\u627E\u56DE\u5BC6\u7801",
|
|
693
|
+
description: "\u9A8C\u8BC1\u7801\u53EA\u4F1A\u53D1\u9001\u5230\u5DF2\u7ECF\u6CE8\u518C\u7684\u90AE\u7BB1\u3002",
|
|
694
|
+
submit: "\u66F4\u65B0\u5BC6\u7801\u5E76\u767B\u5F55"
|
|
695
|
+
};
|
|
696
|
+
return {
|
|
697
|
+
introduction: "\u767B\u5F55\u540E\u53EF\u4EE5\u7BA1\u7406\u4E2A\u4EBA\u8D44\u6599\u4E0E\u767B\u5F55\u4F1A\u8BDD\u3002",
|
|
698
|
+
step: "ACCOUNT / SIGN IN",
|
|
699
|
+
title: "\u767B\u5F55\u8D26\u6237",
|
|
700
|
+
description: "\u4F7F\u7528\u5BC6\u7801\u6216\u90AE\u7BB1\u9A8C\u8BC1\u7801\u767B\u5F55\u4F60\u7684\u8D26\u6237\u3002",
|
|
701
|
+
submit: "\u767B\u5F55"
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
export {
|
|
705
|
+
PasswordForm as default
|
|
706
|
+
};
|