@finueva/auth 0.5.0 → 0.6.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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  `@finueva/auth` bundles browser/runtime code from the packages listed below.
4
4
 
5
- ## @chiballc/utils 2.2.22
5
+ ## @chiballc/utils 2.5.0
6
6
 
7
7
  Source: https://github.com/ChibaLLC/utils
8
8
 
package/dist/device.js CHANGED
@@ -1,45 +1,3 @@
1
- //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
2
- const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
3
- const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
4
- const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
5
- function jsonParseTransform(key, value) {
6
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
7
- warnKeyDropped(key);
8
- return;
9
- }
10
- return value;
11
- }
12
- function warnKeyDropped(key) {
13
- console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
14
- }
15
- function destr(value, options = {}) {
16
- if (typeof value !== "string") return value;
17
- if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
18
- const _value = value.trim();
19
- if (_value.length <= 9) switch (_value.toLowerCase()) {
20
- case "true": return true;
21
- case "false": return false;
22
- case "undefined": return;
23
- case "null": return null;
24
- case "nan": return NaN;
25
- case "infinity": return Number.POSITIVE_INFINITY;
26
- case "-infinity": return Number.NEGATIVE_INFINITY;
27
- }
28
- if (!JsonSigRx.test(value)) {
29
- if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
30
- return value;
31
- }
32
- try {
33
- if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
34
- if (options.strict) throw new Error("[destr] Possible prototype pollution");
35
- return JSON.parse(value, jsonParseTransform);
36
- }
37
- return JSON.parse(value);
38
- } catch (error) {
39
- if (options.strict) throw error;
40
- return value;
41
- }
42
- }
43
1
  String.fromCharCode;
44
2
  const HASH_RE = /#/g;
45
3
  const AMPERSAND_RE = /&/g;
@@ -215,6 +173,49 @@ function stringifyParsedURL(parsed) {
215
173
  return (parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "") + auth + host + pathname + search + hash;
216
174
  }
217
175
  //#endregion
176
+ //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
177
+ const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
178
+ const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
179
+ const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
180
+ function jsonParseTransform(key, value) {
181
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
182
+ warnKeyDropped(key);
183
+ return;
184
+ }
185
+ return value;
186
+ }
187
+ function warnKeyDropped(key) {
188
+ console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
189
+ }
190
+ function destr(value, options = {}) {
191
+ if (typeof value !== "string") return value;
192
+ if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
193
+ const _value = value.trim();
194
+ if (_value.length <= 9) switch (_value.toLowerCase()) {
195
+ case "true": return true;
196
+ case "false": return false;
197
+ case "undefined": return;
198
+ case "null": return null;
199
+ case "nan": return NaN;
200
+ case "infinity": return Number.POSITIVE_INFINITY;
201
+ case "-infinity": return Number.NEGATIVE_INFINITY;
202
+ }
203
+ if (!JsonSigRx.test(value)) {
204
+ if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
205
+ return value;
206
+ }
207
+ try {
208
+ if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
209
+ if (options.strict) throw new Error("[destr] Possible prototype pollution");
210
+ return JSON.parse(value, jsonParseTransform);
211
+ }
212
+ return JSON.parse(value);
213
+ } catch (error) {
214
+ if (options.strict) throw error;
215
+ return value;
216
+ }
217
+ }
218
+ //#endregion
218
219
  //#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs
219
220
  var FetchError = class extends Error {
220
221
  constructor(message, opts) {
@@ -705,7 +706,7 @@ function createDeviceAuth(options) {
705
706
  async function requestAuthorization(requestOptions = {}) {
706
707
  if (requestOptions.signal?.aborted) throw cancelled();
707
708
  try {
708
- return normalizeAuthorization((await requestJsonResponse(`${authOrigin}/api/v1/auth/device/code`, {
709
+ return normalizeAuthorization((await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/device/code"), {
709
710
  fetch: requestFetch,
710
711
  timeoutMs,
711
712
  method: "POST",
@@ -734,7 +735,7 @@ function createDeviceAuth(options) {
734
735
  if (requestBudget <= 0) throw expired();
735
736
  let response;
736
737
  try {
737
- response = await requestJsonResponse(`${authOrigin}/api/v1/auth/device/token`, {
738
+ response = await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/device/token"), {
738
739
  fetch: requestFetch,
739
740
  timeoutMs: Math.min(timeoutMs, requestBudget),
740
741
  method: "POST",
@@ -782,7 +783,7 @@ function createDeviceAuth(options) {
782
783
  const current = await getToken();
783
784
  if (!current) return null;
784
785
  try {
785
- return await requestJsonResponse(`${authOrigin}/api/v1/auth/${path}`, {
786
+ return await requestJsonResponse(joinURL(authOrigin, "api/v1/auth", path), {
786
787
  fetch: requestFetch,
787
788
  timeoutMs,
788
789
  method: body ? "POST" : "GET",
@@ -797,7 +798,7 @@ function createDeviceAuth(options) {
797
798
  const current = await getToken();
798
799
  if (!current) return;
799
800
  try {
800
- await requestJsonResponse(`${authOrigin}/api/v1/auth/${path}`, {
801
+ await requestJsonResponse(joinURL(authOrigin, "api/v1/auth", path), {
801
802
  fetch: requestFetch,
802
803
  timeoutMs,
803
804
  method: "POST",
package/dist/index.js CHANGED
@@ -1635,7 +1635,7 @@ function createAuthClient$1(options) {
1635
1635
  }, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
1636
1636
  }
1637
1637
  //#endregion
1638
- //#region ../../node_modules/.pnpm/@chiballc+utils@2.2.22_magic-string@0.30.21_magicast@0.5.3_rolldown@1.2.0_vite@7.3.6_@t_7ea103523467af2ecb75df55c94dbb80/node_modules/@chiballc/utils/dist/index.mjs
1638
+ //#region ../../node_modules/.pnpm/@chiballc+utils@2.5.0_@hono+zod-openapi@1.5.1_hono@4.13.0_zod@4.4.3__hono@4.13.0_magic-_deb761a9672ce7cf69932b564bd2142d/node_modules/@chiballc/utils/dist/index.mjs
1639
1639
  function isPromise(arg) {
1640
1640
  return arg && typeof arg.then === "function";
1641
1641
  }
@@ -2169,6 +2169,7 @@ function createFetch(globalOptions = {}) {
2169
2169
  }
2170
2170
  //#endregion
2171
2171
  //#region src/shared.ts
2172
+ const DRIVE_CREDENTIAL_LIFETIME_SECONDS = 840;
2172
2173
  const id = /^[A-Za-z0-9_-]{1,128}$/;
2173
2174
  const email = /^[^\s@]+@[^\s@]+$/;
2174
2175
  function normalizeOrigin(value, name) {
@@ -2207,7 +2208,7 @@ function normalizeSession(value) {
2207
2208
  };
2208
2209
  }
2209
2210
  function normalizeDriveCredential(value, now) {
2210
- if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== 900 || typeof value.token !== "string" || value.token.length === 0 || value.token.length + 7 > 16 * 1024) throw authorityUnavailable();
2211
+ if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== DRIVE_CREDENTIAL_LIFETIME_SECONDS || typeof value.token !== "string" || value.token.length === 0 || value.token.length + 7 > 16 * 1024) throw authorityUnavailable();
2211
2212
  return {
2212
2213
  tokenType: "Bearer",
2213
2214
  token: value.token,
package/dist/server.js CHANGED
@@ -466,6 +466,7 @@ var AuthError = class extends Error {
466
466
  };
467
467
  //#endregion
468
468
  //#region src/shared.ts
469
+ const DRIVE_CREDENTIAL_LIFETIME_SECONDS = 840;
469
470
  const id = /^[A-Za-z0-9_-]{1,128}$/;
470
471
  const email = /^[^\s@]+@[^\s@]+$/;
471
472
  function normalizeOrigin(value, name) {
@@ -504,7 +505,7 @@ function normalizeSession(value) {
504
505
  };
505
506
  }
506
507
  function normalizeDriveCredential(value, now) {
507
- if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== 900 || typeof value.token !== "string" || value.token.length === 0 || value.token.length + 7 > 16 * 1024) throw authorityUnavailable();
508
+ if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== DRIVE_CREDENTIAL_LIFETIME_SECONDS || typeof value.token !== "string" || value.token.length === 0 || value.token.length + 7 > 16 * 1024) throw authorityUnavailable();
508
509
  return {
509
510
  tokenType: "Bearer",
510
511
  token: value.token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finueva/auth",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Public browser and server SDK for Finueva Auth",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,7 +48,7 @@
48
48
  "typecheck": "tsc --noEmit"
49
49
  },
50
50
  "devDependencies": {
51
- "@chiballc/utils": "2.2.22",
51
+ "@chiballc/utils": "2.5.0",
52
52
  "@types/node": "24.13.3",
53
53
  "@typescript/native": "npm:typescript@7.0.2",
54
54
  "@vitest/coverage-v8": "4.1.10",