@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 CHANGED
@@ -193,9 +193,13 @@ interface DriveRecipientAuthOptions {
193
193
  fetch?: typeof globalThis.fetch;
194
194
  timeoutMs?: number;
195
195
  }
196
- interface ResolveDriveRecipientInput {
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 (!exact(input, ["email"]) || typeof input.email !== "string") throw new Error();
3127
- email = input.email.trim().toLowerCase();
3128
- if (!validEmail(email)) throw new Error();
3129
- body = JSON.stringify({ email });
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finueva/auth",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Public browser and server SDK for Finueva Auth",
5
5
  "type": "module",
6
6
  "sideEffects": false,