@finueva/auth 0.26.0 → 0.27.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/dist/server.d.ts +6 -2
- package/dist/server.js +11 -5
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -193,9 +193,13 @@ interface DriveRecipientAuthOptions {
|
|
|
193
193
|
fetch?: typeof globalThis.fetch;
|
|
194
194
|
timeoutMs?: number;
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
type ResolveDriveRecipientInput = {
|
|
197
197
|
email: string;
|
|
198
|
-
|
|
198
|
+
userId?: never;
|
|
199
|
+
} | {
|
|
200
|
+
userId: string;
|
|
201
|
+
email?: never;
|
|
202
|
+
};
|
|
199
203
|
interface DriveRecipient {
|
|
200
204
|
userId: string;
|
|
201
205
|
name: string;
|
package/dist/server.js
CHANGED
|
@@ -3122,11 +3122,17 @@ function createDriveRecipientAuth(options) {
|
|
|
3122
3122
|
return { async resolveRecipient(input, clientAssertion) {
|
|
3123
3123
|
let body;
|
|
3124
3124
|
let email;
|
|
3125
|
+
let userId;
|
|
3125
3126
|
try {
|
|
3126
|
-
if (
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3127
|
+
if (exact(input, ["email"]) && typeof input.email === "string") {
|
|
3128
|
+
email = input.email.trim().toLowerCase();
|
|
3129
|
+
if (!validEmail(email)) throw new Error();
|
|
3130
|
+
body = JSON.stringify({ email });
|
|
3131
|
+
} else if (exact(input, ["userId"]) && typeof input.userId === "string") {
|
|
3132
|
+
userId = input.userId;
|
|
3133
|
+
if (!/^[A-Za-z0-9_-]{1,128}$(?![\s\S])/.test(userId)) throw new Error();
|
|
3134
|
+
body = JSON.stringify({ userId });
|
|
3135
|
+
} else throw new Error();
|
|
3130
3136
|
} catch {
|
|
3131
3137
|
throw new AuthError("invalid_request", 400);
|
|
3132
3138
|
}
|
|
@@ -3199,7 +3205,7 @@ function createDriveRecipientAuth(options) {
|
|
|
3199
3205
|
"email"
|
|
3200
3206
|
])) throw authorityUnavailable();
|
|
3201
3207
|
const recipient = value.recipient;
|
|
3202
|
-
if (typeof recipient.userId !== "string" || !/^[A-Za-z0-9_-]{1,128}$(?![\s\S])/.test(recipient.userId) || typeof recipient.name !== "string" || recipient.name.length === 0 || encoder.encode(recipient.name).byteLength > 1024 || !validEmail(recipient.email) || recipient.email !== recipient.email.trim().toLowerCase() || recipient.email !== email) throw authorityUnavailable();
|
|
3208
|
+
if (typeof recipient.userId !== "string" || !/^[A-Za-z0-9_-]{1,128}$(?![\s\S])/.test(recipient.userId) || typeof recipient.name !== "string" || recipient.name.length === 0 || encoder.encode(recipient.name).byteLength > 1024 || !validEmail(recipient.email) || recipient.email !== recipient.email.trim().toLowerCase() || email !== void 0 && recipient.email !== email || userId !== void 0 && recipient.userId !== userId) throw authorityUnavailable();
|
|
3203
3209
|
return {
|
|
3204
3210
|
userId: recipient.userId,
|
|
3205
3211
|
name: recipient.name,
|