@spfn/auth 0.2.0-beta.8 → 0.2.0-beta.80
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 +1 -1
- package/README.md +549 -1819
- package/dist/authenticate-ofdEmk6x.d.ts +1109 -0
- package/dist/config.d.ts +359 -41
- package/dist/config.js +186 -30
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +117 -3
- package/dist/errors.js +83 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +351 -109
- package/dist/index.js +124 -7
- package/dist/index.js.map +1 -1
- package/dist/nextjs/api.js +591 -61
- package/dist/nextjs/api.js.map +1 -1
- package/dist/nextjs/client.d.ts +28 -0
- package/dist/nextjs/client.js +80 -0
- package/dist/nextjs/client.js.map +1 -0
- package/dist/nextjs/server.d.ts +92 -3
- package/dist/nextjs/server.js +288 -24
- package/dist/nextjs/server.js.map +1 -1
- package/dist/server.d.ts +2015 -513
- package/dist/server.js +4198 -1086
- package/dist/server.js.map +1 -1
- package/dist/session-CGxgH3C9.d.ts +53 -0
- package/dist/types-1BMx0OX1.d.ts +84 -0
- package/migrations/0001_smooth_the_fury.sql +3 -0
- package/migrations/0002_deep_iceman.sql +11 -0
- package/migrations/0003_perfect_deathbird.sql +3 -0
- package/migrations/0004_concerned_rawhide_kid.sql +5 -0
- package/migrations/0005_lethal_lifeguard.sql +32 -0
- package/migrations/0006_easy_hardball.sql +24 -0
- package/migrations/0007_glossy_major_mapleleaf.sql +1 -0
- package/migrations/meta/0001_snapshot.json +1660 -0
- package/migrations/meta/0002_snapshot.json +1660 -0
- package/migrations/meta/0003_snapshot.json +1689 -0
- package/migrations/meta/0004_snapshot.json +1721 -0
- package/migrations/meta/0005_snapshot.json +1721 -0
- package/migrations/meta/0006_snapshot.json +1921 -0
- package/migrations/meta/0007_snapshot.json +1916 -0
- package/migrations/meta/_journal.json +49 -0
- package/package.json +43 -39
- package/dist/dto-lZmWuObc.d.ts +0 -645
package/dist/index.js
CHANGED
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
ValidationError,
|
|
16
16
|
UnauthorizedError,
|
|
17
17
|
ForbiddenError,
|
|
18
|
-
ConflictError
|
|
18
|
+
ConflictError,
|
|
19
|
+
NotFoundError
|
|
19
20
|
} from "@spfn/core/errors";
|
|
20
21
|
var InvalidCredentialsError = class extends UnauthorizedError {
|
|
21
22
|
constructor(data = {}) {
|
|
@@ -29,6 +30,12 @@ var InvalidTokenError = class extends UnauthorizedError {
|
|
|
29
30
|
this.name = "InvalidTokenError";
|
|
30
31
|
}
|
|
31
32
|
};
|
|
33
|
+
var InvalidSocialTokenError = class extends UnauthorizedError {
|
|
34
|
+
constructor(data = {}) {
|
|
35
|
+
super({ message: data.message || "Invalid social id_token", details: data.details });
|
|
36
|
+
this.name = "InvalidSocialTokenError";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
32
39
|
var TokenExpiredError = class extends UnauthorizedError {
|
|
33
40
|
constructor(data = {}) {
|
|
34
41
|
super({ message: data.message || "Authentication token has expired", details: data.details });
|
|
@@ -51,6 +58,33 @@ var AccountDisabledError = class extends ForbiddenError {
|
|
|
51
58
|
this.name = "AccountDisabledError";
|
|
52
59
|
}
|
|
53
60
|
};
|
|
61
|
+
var AccountPendingDeletionError = class extends ForbiddenError {
|
|
62
|
+
constructor(data = {}) {
|
|
63
|
+
super({
|
|
64
|
+
message: data.message || "Account is scheduled for deletion",
|
|
65
|
+
details: { status: "pending_deletion", purgeScheduledAt: data.purgeScheduledAt, ...data.details }
|
|
66
|
+
});
|
|
67
|
+
this.name = "AccountPendingDeletionError";
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var DeletionAlreadyRequestedError = class extends ConflictError {
|
|
71
|
+
constructor(data = {}) {
|
|
72
|
+
super({ message: data.message || "Account deletion has already been requested", details: data.details });
|
|
73
|
+
this.name = "DeletionAlreadyRequestedError";
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var DeletionNotRequestedError = class extends NotFoundError {
|
|
77
|
+
constructor(data = {}) {
|
|
78
|
+
super({ message: data.message || "No pending account deletion request found", details: data.details });
|
|
79
|
+
this.name = "DeletionNotRequestedError";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var ImmediateDeletionNotAllowedError = class extends ForbiddenError {
|
|
83
|
+
constructor(data = {}) {
|
|
84
|
+
super({ message: data.message || "Immediate self-service deletion is not enabled", details: data.details });
|
|
85
|
+
this.name = "ImmediateDeletionNotAllowedError";
|
|
86
|
+
}
|
|
87
|
+
};
|
|
54
88
|
var AccountAlreadyExistsError = class extends ConflictError {
|
|
55
89
|
constructor(data = {}) {
|
|
56
90
|
super({
|
|
@@ -64,6 +98,12 @@ var AccountAlreadyExistsError = class extends ConflictError {
|
|
|
64
98
|
this.name = "AccountAlreadyExistsError";
|
|
65
99
|
}
|
|
66
100
|
};
|
|
101
|
+
var RegistrationRejectedError = class extends ForbiddenError {
|
|
102
|
+
constructor(data = {}) {
|
|
103
|
+
super({ message: data.message || "Registration rejected", details: data.details });
|
|
104
|
+
this.name = "RegistrationRejectedError";
|
|
105
|
+
}
|
|
106
|
+
};
|
|
67
107
|
var InvalidVerificationCodeError = class extends ValidationError {
|
|
68
108
|
constructor(data = {}) {
|
|
69
109
|
super({ message: data.message || "Invalid verification code", details: data.details });
|
|
@@ -102,6 +142,24 @@ var VerificationTokenTargetMismatchError = class extends ValidationError {
|
|
|
102
142
|
this.name = "VerificationTokenTargetMismatchError";
|
|
103
143
|
}
|
|
104
144
|
};
|
|
145
|
+
var ReservedUsernameError = class extends ValidationError {
|
|
146
|
+
constructor(data = {}) {
|
|
147
|
+
super({
|
|
148
|
+
message: data.message || "This username is reserved",
|
|
149
|
+
details: { username: data.username, ...data.details }
|
|
150
|
+
});
|
|
151
|
+
this.name = "ReservedUsernameError";
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var UsernameAlreadyTakenError = class extends ConflictError {
|
|
155
|
+
constructor(data = {}) {
|
|
156
|
+
super({
|
|
157
|
+
message: data.message || "Username is already taken",
|
|
158
|
+
details: { username: data.username, ...data.details }
|
|
159
|
+
});
|
|
160
|
+
this.name = "UsernameAlreadyTakenError";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
105
163
|
var InsufficientPermissionsError = class extends ForbiddenError {
|
|
106
164
|
constructor(data = {}) {
|
|
107
165
|
const requiredPermissions = data.requiredPermissions || [];
|
|
@@ -128,10 +186,18 @@ var authErrorRegistry = new ErrorRegistry();
|
|
|
128
186
|
authErrorRegistry.append([
|
|
129
187
|
InvalidCredentialsError,
|
|
130
188
|
InvalidTokenError,
|
|
189
|
+
InvalidSocialTokenError,
|
|
131
190
|
TokenExpiredError,
|
|
132
191
|
KeyExpiredError,
|
|
133
192
|
AccountDisabledError,
|
|
193
|
+
AccountPendingDeletionError,
|
|
194
|
+
DeletionAlreadyRequestedError,
|
|
195
|
+
DeletionNotRequestedError,
|
|
196
|
+
ImmediateDeletionNotAllowedError,
|
|
134
197
|
AccountAlreadyExistsError,
|
|
198
|
+
RegistrationRejectedError,
|
|
199
|
+
ReservedUsernameError,
|
|
200
|
+
UsernameAlreadyTakenError,
|
|
135
201
|
InvalidVerificationCodeError,
|
|
136
202
|
InvalidVerificationTokenError,
|
|
137
203
|
InvalidKeyFingerprintError,
|
|
@@ -141,6 +207,48 @@ authErrorRegistry.append([
|
|
|
141
207
|
InsufficientRoleError
|
|
142
208
|
]);
|
|
143
209
|
|
|
210
|
+
// src/generated/route-map.ts
|
|
211
|
+
var routeMap = {
|
|
212
|
+
sendVerificationCode: { method: "POST", path: "/_auth/codes" },
|
|
213
|
+
verifyCode: { method: "POST", path: "/_auth/codes/verify" },
|
|
214
|
+
register: { method: "POST", path: "/_auth/register" },
|
|
215
|
+
login: { method: "POST", path: "/_auth/login" },
|
|
216
|
+
logout: { method: "POST", path: "/_auth/logout" },
|
|
217
|
+
rotateKey: { method: "POST", path: "/_auth/keys/rotate" },
|
|
218
|
+
changePassword: { method: "PUT", path: "/_auth/password" },
|
|
219
|
+
getAuthSession: { method: "GET", path: "/_auth/session" },
|
|
220
|
+
issueOneTimeToken: { method: "POST", path: "/_auth/tokens" },
|
|
221
|
+
getInvitation: { method: "GET", path: "/_auth/invitations/:token" },
|
|
222
|
+
acceptInvitation: { method: "POST", path: "/_auth/invitations/accept" },
|
|
223
|
+
createInvitation: { method: "POST", path: "/_auth/invitations" },
|
|
224
|
+
listInvitations: { method: "GET", path: "/_auth/invitations" },
|
|
225
|
+
cancelInvitation: { method: "POST", path: "/_auth/invitations/cancel" },
|
|
226
|
+
resendInvitation: { method: "POST", path: "/_auth/invitations/resend" },
|
|
227
|
+
deleteInvitation: { method: "POST", path: "/_auth/invitations/delete" },
|
|
228
|
+
getUserProfile: { method: "GET", path: "/_auth/users/profile" },
|
|
229
|
+
updateUserProfile: { method: "PATCH", path: "/_auth/users/profile" },
|
|
230
|
+
checkUsername: { method: "GET", path: "/_auth/users/username/check" },
|
|
231
|
+
updateUsername: { method: "PATCH", path: "/_auth/users/username" },
|
|
232
|
+
updateLocale: { method: "PATCH", path: "/_auth/users/locale" },
|
|
233
|
+
oauthGoogleStart: { method: "GET", path: "/_auth/oauth/google" },
|
|
234
|
+
oauthGoogleCallback: { method: "GET", path: "/_auth/oauth/google/callback" },
|
|
235
|
+
oauthStart: { method: "POST", path: "/_auth/oauth/start" },
|
|
236
|
+
oauthProviders: { method: "GET", path: "/_auth/oauth/providers" },
|
|
237
|
+
getGoogleOAuthUrl: { method: "POST", path: "/_auth/oauth/google/url" },
|
|
238
|
+
oauthFinalize: { method: "POST", path: "/_auth/oauth/finalize" },
|
|
239
|
+
oauthProviderStart: { method: "GET", path: "/_auth/oauth/:provider" },
|
|
240
|
+
oauthProviderCallback: { method: "GET", path: "/_auth/oauth/:provider/callback" },
|
|
241
|
+
getProviderOAuthUrl: { method: "POST", path: "/_auth/oauth/:provider/url" },
|
|
242
|
+
oauthNative: { method: "POST", path: "/_auth/oauth/:provider/native" },
|
|
243
|
+
listRoles: { method: "GET", path: "/_auth/admin/roles" },
|
|
244
|
+
createAdminRole: { method: "POST", path: "/_auth/admin/roles" },
|
|
245
|
+
updateAdminRole: { method: "PATCH", path: "/_auth/admin/roles/:id" },
|
|
246
|
+
deleteAdminRole: { method: "DELETE", path: "/_auth/admin/roles/:id" },
|
|
247
|
+
updateUserRole: { method: "PATCH", path: "/_auth/admin/users/:userId/role" },
|
|
248
|
+
requestAccountDeletion: { method: "POST", path: "/_auth/deletion/request" },
|
|
249
|
+
cancelAccountDeletion: { method: "POST", path: "/_auth/deletion/cancel" }
|
|
250
|
+
};
|
|
251
|
+
|
|
144
252
|
// src/lib/types.ts
|
|
145
253
|
var EMAIL_PATTERN = "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
|
|
146
254
|
var PHONE_PATTERN = "^\\+[1-9]\\d{1,14}$";
|
|
@@ -275,8 +383,11 @@ var BUILTIN_ROLE_PERMISSIONS = {
|
|
|
275
383
|
// src/server/types.ts
|
|
276
384
|
var KEY_ALGORITHM = ["ES256", "RS256"];
|
|
277
385
|
var INVITATION_STATUSES = ["pending", "accepted", "expired", "cancelled"];
|
|
278
|
-
var USER_STATUSES = ["active", "inactive", "suspended"];
|
|
279
|
-
var SOCIAL_PROVIDERS = ["google", "github", "kakao", "naver"];
|
|
386
|
+
var USER_STATUSES = ["active", "inactive", "suspended", "pending_deletion", "deleted"];
|
|
387
|
+
var SOCIAL_PROVIDERS = ["google", "apple", "github", "kakao", "naver", "superself"];
|
|
388
|
+
var ACCOUNT_DELETION_REQUEST_STATUSES = ["pending", "cancelled", "completed"];
|
|
389
|
+
var ACCOUNT_DELETION_REQUESTED_BY = ["self", "admin"];
|
|
390
|
+
var PURGE_STRATEGIES = ["anonymize", "hard-delete"];
|
|
280
391
|
|
|
281
392
|
// ../../node_modules/.pnpm/@sinclair+typebox@0.34.41/node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
282
393
|
var value_exports = {};
|
|
@@ -2901,7 +3012,8 @@ var PhoneSchema = Type.String({
|
|
|
2901
3012
|
});
|
|
2902
3013
|
var PasswordSchema = Type.String({
|
|
2903
3014
|
minLength: 8,
|
|
2904
|
-
|
|
3015
|
+
maxLength: 72,
|
|
3016
|
+
description: "User password (8\u201372 characters). bcrypt silently ignores bytes past 72, so longer inputs are rejected rather than truncated."
|
|
2905
3017
|
});
|
|
2906
3018
|
var TargetTypeSchema = Type.Union([
|
|
2907
3019
|
Type.Literal("email"),
|
|
@@ -2915,17 +3027,20 @@ var VerificationPurposeSchema = Type.Union([
|
|
|
2915
3027
|
Type.Literal("login"),
|
|
2916
3028
|
Type.Literal("password_reset"),
|
|
2917
3029
|
Type.Literal("email_change"),
|
|
2918
|
-
Type.Literal("phone_change")
|
|
3030
|
+
Type.Literal("phone_change"),
|
|
3031
|
+
Type.Literal("account_deletion")
|
|
2919
3032
|
], {
|
|
2920
3033
|
description: "Purpose of verification"
|
|
2921
3034
|
});
|
|
2922
|
-
var VERIFICATION_PURPOSES = ["registration", "login", "password_reset", "email_change", "phone_change"];
|
|
3035
|
+
var VERIFICATION_PURPOSES = ["registration", "login", "password_reset", "email_change", "phone_change", "account_deletion"];
|
|
2923
3036
|
|
|
2924
3037
|
// src/index.ts
|
|
2925
3038
|
var authApi = createApi({
|
|
2926
3039
|
errorRegistry: [authErrorRegistry]
|
|
2927
3040
|
});
|
|
2928
3041
|
export {
|
|
3042
|
+
ACCOUNT_DELETION_REQUESTED_BY,
|
|
3043
|
+
ACCOUNT_DELETION_REQUEST_STATUSES,
|
|
2929
3044
|
BASE64_PATTERN,
|
|
2930
3045
|
BUILTIN_PERMISSIONS,
|
|
2931
3046
|
BUILTIN_ROLES,
|
|
@@ -2936,11 +3051,13 @@ export {
|
|
|
2936
3051
|
KEY_ALGORITHM,
|
|
2937
3052
|
PERMISSION_CATEGORIES,
|
|
2938
3053
|
PHONE_PATTERN,
|
|
3054
|
+
PURGE_STRATEGIES,
|
|
2939
3055
|
SOCIAL_PROVIDERS,
|
|
2940
3056
|
USER_STATUSES,
|
|
2941
3057
|
UUID_PATTERN,
|
|
2942
3058
|
VERIFICATION_PURPOSES,
|
|
2943
3059
|
VERIFICATION_TARGET_TYPES,
|
|
2944
|
-
authApi
|
|
3060
|
+
authApi,
|
|
3061
|
+
routeMap as authRouteMap
|
|
2945
3062
|
};
|
|
2946
3063
|
//# sourceMappingURL=index.js.map
|