@shware/http 2.11.0 → 2.11.2

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.
@@ -32,10 +32,10 @@ function loadScript() {
32
32
  resolve();
33
33
  } else {
34
34
  script.addEventListener("load", () => resolve());
35
- script.addEventListener(
36
- "error",
37
- () => reject(new Error("Failed to load Google One Tap script"))
38
- );
35
+ script.addEventListener("error", () => {
36
+ script = null;
37
+ reject(new Error("Failed to load Google One Tap script"));
38
+ });
39
39
  }
40
40
  return;
41
41
  }
@@ -45,7 +45,10 @@ function loadScript() {
45
45
  script.defer = true;
46
46
  script.src = "https://accounts.google.com/gsi/client";
47
47
  script.onload = () => resolve();
48
- script.onerror = () => reject(new Error("Failed to load Google One Tap script"));
48
+ script.onerror = () => {
49
+ script = null;
50
+ reject(new Error("Failed to load Google One Tap script"));
51
+ };
49
52
  document.head.appendChild(script);
50
53
  });
51
54
  }
@@ -88,15 +91,13 @@ async function prompt({
88
91
  });
89
92
  window.google.accounts.id.prompt((notification) => {
90
93
  if (settled) return;
91
- if (notification.isSkippedMoment() || notification.isDismissedMoment() && notification.getDismissedReason() !== "credential_returned") {
94
+ const skipped = notification.isSkippedMoment();
95
+ const dismissed = notification.isDismissedMoment();
96
+ const dismissedReason = notification.getDismissedReason();
97
+ if (skipped || dismissed && dismissedReason !== "credential_returned") {
92
98
  settle({
93
99
  authorized: false,
94
- moment: {
95
- momentType: notification.getMomentType(),
96
- skipped: notification.isSkippedMoment(),
97
- dismissed: notification.isDismissedMoment(),
98
- dismissedReason: notification.getDismissedReason()
99
- }
100
+ moment: { skipped, dismissed, dismissedReason }
100
101
  });
101
102
  }
102
103
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type {\n ClientConfigError,\n CodeResponse,\n CredentialResponse,\n GoogleAccounts,\n PromptMomentNotification,\n} from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n /**\n * Opaque nonce string forwarded as-is to Google. Google echoes it back in\n * the ID Token's `nonce` claim per the OIDC spec; the caller is responsible\n * for any hashing/encoding required by its verifier.\n */\n nonce?: string;\n client_id: string;\n auto_select?: boolean;\n cancel_on_tap_outside?: boolean;\n use_fedcm_for_prompt?: boolean;\n};\n\nexport type PromptMoment = {\n skipped: boolean;\n dismissed: boolean;\n momentType: ReturnType<PromptMomentNotification['getMomentType']>;\n dismissedReason: ReturnType<PromptMomentNotification['getDismissedReason']>;\n};\n\n/**\n * Why prompt() could not run One Tap, so the caller can decide to fall back\n * to requestCode().\n * - `fedcm_unsupported`: browser has no FedCM (Safari/Firefox/pre-117 Chrome).\n * - `script_load_failed`: the GSI script failed to load (network/CSP).\n * - `prompt_error`: GIS threw synchronously while initializing/prompting.\n */\nexport type UnsupportedReason = 'fedcm_unsupported' | 'script_load_failed' | 'prompt_error';\n\nexport type PromptResult =\n | { authorized: true; credential: CredentialResponse }\n | { authorized: false; moment: PromptMoment }\n | { authorized: false; unsupported: true; reason: UnsupportedReason };\n\nlet script: HTMLScriptElement | null = null;\n\nfunction loadScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n if (script) {\n if (window.google?.accounts?.id) {\n resolve();\n } else {\n script.addEventListener('load', () => resolve());\n script.addEventListener('error', () =>\n reject(new Error('Failed to load Google One Tap script'))\n );\n }\n return;\n }\n\n script = document.createElement('script');\n script.id = 'google-one-tap';\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => resolve();\n script.onerror = () => reject(new Error('Failed to load Google One Tap script'));\n\n document.head.appendChild(script);\n });\n}\n\n/** FedCM feature detection — `IdentityCredential` is absent on Safari, Firefox and pre-117 Chrome. */\nfunction isFedcmSupported(): boolean {\n return typeof window !== 'undefined' && 'IdentityCredential' in window;\n}\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport async function prompt({\n nonce,\n client_id,\n auto_select = false,\n use_fedcm_for_prompt = true,\n cancel_on_tap_outside = false,\n}: Props): Promise<PromptResult> {\n // FedCM is mandatory for One Tap on capable browsers (GIS completed the\n // migration in early 2025) and there is no viable legacy fallback anymore.\n // When the caller wants FedCM but the browser lacks it, bail early instead\n // of letting GIS throw an async `NotSupportedError: Missing request type`\n // from navigator.credentials.get. Callers should fall back to requestCode().\n if (use_fedcm_for_prompt !== false && !isFedcmSupported()) {\n return { authorized: false, unsupported: true, reason: 'fedcm_unsupported' };\n }\n\n try {\n await loadScript();\n } catch {\n return { authorized: false, unsupported: true, reason: 'script_load_failed' };\n }\n\n return new Promise<PromptResult>((resolve) => {\n let settled = false;\n const settle = (result: PromptResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n try {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select,\n nonce,\n client_id,\n use_fedcm_for_prompt,\n cancel_on_tap_outside,\n callback: (credential) => settle({ authorized: true, credential }),\n native_callback: (credential) => settle({ authorized: true, credential }),\n });\n\n window.google.accounts.id.prompt((notification) => {\n if (settled) return;\n\n if (\n notification.isSkippedMoment() ||\n (notification.isDismissedMoment() &&\n notification.getDismissedReason() !== 'credential_returned')\n ) {\n settle({\n authorized: false,\n moment: {\n momentType: notification.getMomentType(),\n skipped: notification.isSkippedMoment(),\n dismissed: notification.isDismissedMoment(),\n dismissedReason: notification.getDismissedReason(),\n },\n });\n }\n });\n } catch {\n settle({ authorized: false, unsupported: true, reason: 'prompt_error' });\n }\n });\n}\n\nexport type CodeProps = {\n client_id: string;\n /**\n * Space-delimited OAuth scopes. Defaults to OpenID Connect scopes so the\n * backend can exchange the code for an ID token, mirroring One Tap's intent.\n */\n scope?: string;\n /** 'popup' resolves the returned promise; 'redirect' navigates away and never resolves. */\n ux_mode?: 'popup' | 'redirect';\n /** Required when ux_mode is 'redirect'; for 'popup' Google uses postMessage. */\n redirect_uri?: string;\n state?: string;\n login_hint?: string;\n hd?: string;\n};\n\nexport type CodeResult =\n | { ok: true; response: CodeResponse }\n | { ok: false; error: ClientConfigError | CodeResponse };\n\n/**\n * OAuth 2.0 authorization-code fallback for environments where One Tap / FedCM\n * is unavailable (i.e. prompt() resolved with `unsupported: true`). It reuses\n * the same GSI script, so there is no extra dependency.\n *\n * Unlike One Tap it returns an authorization `code` for the backend to\n * exchange, not an ID token, and it must be triggered by a user gesture or the\n * popup may be blocked.\n */\nexport async function requestCode({\n client_id,\n scope = 'openid email profile',\n ux_mode = 'popup',\n redirect_uri,\n state,\n login_hint,\n hd,\n}: CodeProps): Promise<CodeResult> {\n await loadScript();\n\n return new Promise<CodeResult>((resolve) => {\n let settled = false;\n const settle = (result: CodeResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n const client = window.google.accounts.oauth2.initCodeClient({\n client_id,\n scope,\n ux_mode,\n redirect_uri,\n state,\n login_hint,\n hd,\n callback: (response) =>\n settle(response.code ? { ok: true, response } : { ok: false, error: response }),\n error_callback: (error) => settle({ ok: false, error }),\n });\n\n client.requestCode();\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDA,IAAI,SAAmC;AAEvC,SAAS,aAA4B;AACnC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,QAAI,QAAQ;AACV,UAAI,OAAO,QAAQ,UAAU,IAAI;AAC/B,gBAAQ;AAAA,MACV,OAAO;AACL,eAAO,iBAAiB,QAAQ,MAAM,QAAQ,CAAC;AAC/C,eAAO;AAAA,UAAiB;AAAA,UAAS,MAC/B,OAAO,IAAI,MAAM,sCAAsC,CAAC;AAAA,QAC1D;AAAA,MACF;AACA;AAAA,IACF;AAEA,aAAS,SAAS,cAAc,QAAQ;AACxC,WAAO,KAAK;AACZ,WAAO,QAAQ;AACf,WAAO,QAAQ;AACf,WAAO,MAAM;AACb,WAAO,SAAS,MAAM,QAAQ;AAC9B,WAAO,UAAU,MAAM,OAAO,IAAI,MAAM,sCAAsC,CAAC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B;AAAA,YACnD;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AACN,aAAO,EAAE,YAAY,OAAO,aAAa,MAAM,QAAQ,eAAe,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACH;AA+BA,eAAsB,YAAY;AAAA,EAChC;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,QAAM,WAAW;AAEjB,SAAO,IAAI,QAAoB,CAAC,YAAY;AAC1C,QAAI,UAAU;AACd,UAAM,SAAS,CAAC,WAAuB;AACrC,UAAI,QAAS;AACb,gBAAU;AACV,cAAQ,MAAM;AAAA,IAChB;AAEA,UAAM,SAAS,OAAO,OAAO,SAAS,OAAO,eAAe;AAAA,MAC1D;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,CAAC,aACT,OAAO,SAAS,OAAO,EAAE,IAAI,MAAM,SAAS,IAAI,EAAE,IAAI,OAAO,OAAO,SAAS,CAAC;AAAA,MAChF,gBAAgB,CAAC,UAAU,OAAO,EAAE,IAAI,OAAO,MAAM,CAAC;AAAA,IACxD,CAAC;AAED,WAAO,YAAY;AAAA,EACrB,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type {\n ClientConfigError,\n CodeResponse,\n CredentialResponse,\n GoogleAccounts,\n PromptMomentNotification,\n} from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n /**\n * Opaque nonce string forwarded as-is to Google. Google echoes it back in\n * the ID Token's `nonce` claim per the OIDC spec; the caller is responsible\n * for any hashing/encoding required by its verifier.\n */\n nonce?: string;\n client_id: string;\n auto_select?: boolean;\n cancel_on_tap_outside?: boolean;\n use_fedcm_for_prompt?: boolean;\n};\n\nexport type PromptMoment = {\n skipped: boolean;\n dismissed: boolean;\n dismissedReason: ReturnType<PromptMomentNotification['getDismissedReason']>;\n};\n\n/**\n * Why prompt() could not run One Tap, so the caller can decide to fall back\n * to requestCode().\n * - `fedcm_unsupported`: browser has no FedCM (Safari/Firefox/pre-117 Chrome).\n * - `script_load_failed`: the GSI script failed to load (network/CSP).\n * - `prompt_error`: GIS threw synchronously while initializing/prompting.\n */\nexport type UnsupportedReason = 'fedcm_unsupported' | 'script_load_failed' | 'prompt_error';\n\nexport type PromptResult =\n | { authorized: true; credential: CredentialResponse }\n | { authorized: false; moment: PromptMoment }\n | { authorized: false; unsupported: true; reason: UnsupportedReason };\n\nlet script: HTMLScriptElement | null = null;\n\nfunction loadScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n if (script) {\n if (window.google?.accounts?.id) {\n resolve();\n } else {\n script.addEventListener('load', () => resolve());\n script.addEventListener('error', () => {\n script = null; // allow a later call to recreate the element instead of hanging\n reject(new Error('Failed to load Google One Tap script'));\n });\n }\n return;\n }\n\n script = document.createElement('script');\n script.id = 'google-one-tap';\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => resolve();\n script.onerror = () => {\n script = null; // allow a later call to recreate the element instead of hanging\n reject(new Error('Failed to load Google One Tap script'));\n };\n\n document.head.appendChild(script);\n });\n}\n\n/** FedCM feature detection — `IdentityCredential` is absent on Safari, Firefox and pre-117 Chrome. */\nfunction isFedcmSupported(): boolean {\n return typeof window !== 'undefined' && 'IdentityCredential' in window;\n}\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport async function prompt({\n nonce,\n client_id,\n auto_select = false,\n use_fedcm_for_prompt = true,\n cancel_on_tap_outside = false,\n}: Props): Promise<PromptResult> {\n // FedCM is mandatory for One Tap on capable browsers (GIS completed the\n // migration in early 2025) and there is no viable legacy fallback anymore.\n // When the caller wants FedCM but the browser lacks it, bail early instead\n // of letting GIS throw an async `NotSupportedError: Missing request type`\n // from navigator.credentials.get. Callers should fall back to requestCode().\n if (use_fedcm_for_prompt !== false && !isFedcmSupported()) {\n return { authorized: false, unsupported: true, reason: 'fedcm_unsupported' };\n }\n\n try {\n await loadScript();\n } catch {\n return { authorized: false, unsupported: true, reason: 'script_load_failed' };\n }\n\n return new Promise<PromptResult>((resolve) => {\n let settled = false;\n const settle = (result: PromptResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n try {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select,\n nonce,\n client_id,\n use_fedcm_for_prompt,\n cancel_on_tap_outside,\n callback: (credential) => settle({ authorized: true, credential }),\n native_callback: (credential) => settle({ authorized: true, credential }),\n });\n\n window.google.accounts.id.prompt((notification) => {\n if (settled) return;\n\n const skipped = notification.isSkippedMoment();\n const dismissed = notification.isDismissedMoment();\n const dismissedReason = notification.getDismissedReason();\n\n if (skipped || (dismissed && dismissedReason !== 'credential_returned')) {\n settle({\n authorized: false,\n moment: { skipped, dismissed, dismissedReason },\n });\n }\n });\n } catch {\n settle({ authorized: false, unsupported: true, reason: 'prompt_error' });\n }\n });\n}\n\nexport type CodeProps = {\n client_id: string;\n /**\n * Space-delimited OAuth scopes. Defaults to OpenID Connect scopes so the\n * backend can exchange the code for an ID token, mirroring One Tap's intent.\n */\n scope?: string;\n /** 'popup' resolves the returned promise; 'redirect' navigates away and never resolves. */\n ux_mode?: 'popup' | 'redirect';\n /** Required when ux_mode is 'redirect'; for 'popup' Google uses postMessage. */\n redirect_uri?: string;\n state?: string;\n login_hint?: string;\n hd?: string;\n};\n\nexport type CodeResult =\n | { ok: true; response: CodeResponse }\n | { ok: false; error: ClientConfigError | CodeResponse };\n\n/**\n * OAuth 2.0 authorization-code fallback for environments where One Tap / FedCM\n * is unavailable (i.e. prompt() resolved with `unsupported: true`). It reuses\n * the same GSI script, so there is no extra dependency.\n *\n * Unlike One Tap it returns an authorization `code` for the backend to\n * exchange, not an ID token, and it must be triggered by a user gesture or the\n * popup may be blocked.\n */\nexport async function requestCode({\n client_id,\n scope = 'openid email profile',\n ux_mode = 'popup',\n redirect_uri,\n state,\n login_hint,\n hd,\n}: CodeProps): Promise<CodeResult> {\n await loadScript();\n\n return new Promise<CodeResult>((resolve) => {\n let settled = false;\n const settle = (result: CodeResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n const client = window.google.accounts.oauth2.initCodeClient({\n client_id,\n scope,\n ux_mode,\n redirect_uri,\n state,\n login_hint,\n hd,\n callback: (response) =>\n settle(response.code ? { ok: true, response } : { ok: false, error: response }),\n error_callback: (error) => settle({ ok: false, error }),\n });\n\n client.requestCode();\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiDA,IAAI,SAAmC;AAEvC,SAAS,aAA4B;AACnC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,QAAI,QAAQ;AACV,UAAI,OAAO,QAAQ,UAAU,IAAI;AAC/B,gBAAQ;AAAA,MACV,OAAO;AACL,eAAO,iBAAiB,QAAQ,MAAM,QAAQ,CAAC;AAC/C,eAAO,iBAAiB,SAAS,MAAM;AACrC,mBAAS;AACT,iBAAO,IAAI,MAAM,sCAAsC,CAAC;AAAA,QAC1D,CAAC;AAAA,MACH;AACA;AAAA,IACF;AAEA,aAAS,SAAS,cAAc,QAAQ;AACxC,WAAO,KAAK;AACZ,WAAO,QAAQ;AACf,WAAO,QAAQ;AACf,WAAO,MAAM;AACb,WAAO,SAAS,MAAM,QAAQ;AAC9B,WAAO,UAAU,MAAM;AACrB,eAAS;AACT,aAAO,IAAI,MAAM,sCAAsC,CAAC;AAAA,IAC1D;AAEA,aAAS,KAAK,YAAY,MAAM;AAAA,EAClC,CAAC;AACH;AAGA,SAAS,mBAA4B;AACnC,SAAO,OAAO,WAAW,eAAe,wBAAwB;AAClE;AAGA,eAAsB,OAAO;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,uBAAuB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AA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,QAAM,WAAW;AAEjB,SAAO,IAAI,QAAoB,CAAC,YAAY;AAC1C,QAAI,UAAU;AACd,UAAM,SAAS,CAAC,WAAuB;AACrC,UAAI,QAAS;AACb,gBAAU;AACV,cAAQ,MAAM;AAAA,IAChB;AAEA,UAAM,SAAS,OAAO,OAAO,SAAS,OAAO,eAAe;AAAA,MAC1D;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,CAAC,aACT,OAAO,SAAS,OAAO,EAAE,IAAI,MAAM,SAAS,IAAI,EAAE,IAAI,OAAO,OAAO,SAAS,CAAC;AAAA,MAChF,gBAAgB,CAAC,UAAU,OAAO,EAAE,IAAI,OAAO,MAAM,CAAC;AAAA,IACxD,CAAC;AAED,WAAO,YAAY;AAAA,EACrB,CAAC;AACH;","names":[]}
@@ -1,4 +1,4 @@
1
- import { GoogleAccounts, PromptMomentNotification, CredentialResponse, CodeResponse, ClientConfigError } from './types.cjs';
1
+ import { GoogleAccounts, CodeResponse, ClientConfigError, PromptMomentNotification, CredentialResponse } from './types.cjs';
2
2
 
3
3
  declare global {
4
4
  interface Window {
@@ -22,7 +22,6 @@ type Props = {
22
22
  type PromptMoment = {
23
23
  skipped: boolean;
24
24
  dismissed: boolean;
25
- momentType: ReturnType<PromptMomentNotification['getMomentType']>;
26
25
  dismissedReason: ReturnType<PromptMomentNotification['getDismissedReason']>;
27
26
  };
28
27
  /**
@@ -1,4 +1,4 @@
1
- import { GoogleAccounts, PromptMomentNotification, CredentialResponse, CodeResponse, ClientConfigError } from './types.js';
1
+ import { GoogleAccounts, CodeResponse, ClientConfigError, PromptMomentNotification, CredentialResponse } from './types.js';
2
2
 
3
3
  declare global {
4
4
  interface Window {
@@ -22,7 +22,6 @@ type Props = {
22
22
  type PromptMoment = {
23
23
  skipped: boolean;
24
24
  dismissed: boolean;
25
- momentType: ReturnType<PromptMomentNotification['getMomentType']>;
26
25
  dismissedReason: ReturnType<PromptMomentNotification['getDismissedReason']>;
27
26
  };
28
27
  /**
@@ -7,10 +7,10 @@ function loadScript() {
7
7
  resolve();
8
8
  } else {
9
9
  script.addEventListener("load", () => resolve());
10
- script.addEventListener(
11
- "error",
12
- () => reject(new Error("Failed to load Google One Tap script"))
13
- );
10
+ script.addEventListener("error", () => {
11
+ script = null;
12
+ reject(new Error("Failed to load Google One Tap script"));
13
+ });
14
14
  }
15
15
  return;
16
16
  }
@@ -20,7 +20,10 @@ function loadScript() {
20
20
  script.defer = true;
21
21
  script.src = "https://accounts.google.com/gsi/client";
22
22
  script.onload = () => resolve();
23
- script.onerror = () => reject(new Error("Failed to load Google One Tap script"));
23
+ script.onerror = () => {
24
+ script = null;
25
+ reject(new Error("Failed to load Google One Tap script"));
26
+ };
24
27
  document.head.appendChild(script);
25
28
  });
26
29
  }
@@ -63,15 +66,13 @@ async function prompt({
63
66
  });
64
67
  window.google.accounts.id.prompt((notification) => {
65
68
  if (settled) return;
66
- if (notification.isSkippedMoment() || notification.isDismissedMoment() && notification.getDismissedReason() !== "credential_returned") {
69
+ const skipped = notification.isSkippedMoment();
70
+ const dismissed = notification.isDismissedMoment();
71
+ const dismissedReason = notification.getDismissedReason();
72
+ if (skipped || dismissed && dismissedReason !== "credential_returned") {
67
73
  settle({
68
74
  authorized: false,
69
- moment: {
70
- momentType: notification.getMomentType(),
71
- skipped: notification.isSkippedMoment(),
72
- dismissed: notification.isDismissedMoment(),
73
- dismissedReason: notification.getDismissedReason()
74
- }
75
+ moment: { skipped, dismissed, dismissedReason }
75
76
  });
76
77
  }
77
78
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type {\n ClientConfigError,\n CodeResponse,\n CredentialResponse,\n GoogleAccounts,\n PromptMomentNotification,\n} from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n /**\n * Opaque nonce string forwarded as-is to Google. Google echoes it back in\n * the ID Token's `nonce` claim per the OIDC spec; the caller is responsible\n * for any hashing/encoding required by its verifier.\n */\n nonce?: string;\n client_id: string;\n auto_select?: boolean;\n cancel_on_tap_outside?: boolean;\n use_fedcm_for_prompt?: boolean;\n};\n\nexport type PromptMoment = {\n skipped: boolean;\n dismissed: boolean;\n momentType: ReturnType<PromptMomentNotification['getMomentType']>;\n dismissedReason: ReturnType<PromptMomentNotification['getDismissedReason']>;\n};\n\n/**\n * Why prompt() could not run One Tap, so the caller can decide to fall back\n * to requestCode().\n * - `fedcm_unsupported`: browser has no FedCM (Safari/Firefox/pre-117 Chrome).\n * - `script_load_failed`: the GSI script failed to load (network/CSP).\n * - `prompt_error`: GIS threw synchronously while initializing/prompting.\n */\nexport type UnsupportedReason = 'fedcm_unsupported' | 'script_load_failed' | 'prompt_error';\n\nexport type PromptResult =\n | { authorized: true; credential: CredentialResponse }\n | { authorized: false; moment: PromptMoment }\n | { authorized: false; unsupported: true; reason: UnsupportedReason };\n\nlet script: HTMLScriptElement | null = null;\n\nfunction loadScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n if (script) {\n if (window.google?.accounts?.id) {\n resolve();\n } else {\n script.addEventListener('load', () => resolve());\n script.addEventListener('error', () =>\n reject(new Error('Failed to load Google One Tap script'))\n );\n }\n return;\n }\n\n script = document.createElement('script');\n script.id = 'google-one-tap';\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => resolve();\n script.onerror = () => reject(new Error('Failed to load Google One Tap script'));\n\n document.head.appendChild(script);\n });\n}\n\n/** FedCM feature detection — `IdentityCredential` is absent on Safari, Firefox and pre-117 Chrome. */\nfunction isFedcmSupported(): boolean {\n return typeof window !== 'undefined' && 'IdentityCredential' in window;\n}\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport async function prompt({\n nonce,\n client_id,\n auto_select = false,\n use_fedcm_for_prompt = true,\n cancel_on_tap_outside = false,\n}: Props): Promise<PromptResult> {\n // FedCM is mandatory for One Tap on capable browsers (GIS completed the\n // migration in early 2025) and there is no viable legacy fallback anymore.\n // When the caller wants FedCM but the browser lacks it, bail early instead\n // of letting GIS throw an async `NotSupportedError: Missing request type`\n // from navigator.credentials.get. Callers should fall back to requestCode().\n if (use_fedcm_for_prompt !== false && !isFedcmSupported()) {\n return { authorized: false, unsupported: true, reason: 'fedcm_unsupported' };\n }\n\n try {\n await loadScript();\n } catch {\n return { authorized: false, unsupported: true, reason: 'script_load_failed' };\n }\n\n return new Promise<PromptResult>((resolve) => {\n let settled = false;\n const settle = (result: PromptResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n try {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select,\n nonce,\n client_id,\n use_fedcm_for_prompt,\n cancel_on_tap_outside,\n callback: (credential) => settle({ authorized: true, credential }),\n native_callback: (credential) => settle({ authorized: true, credential }),\n });\n\n window.google.accounts.id.prompt((notification) => {\n if (settled) return;\n\n if (\n notification.isSkippedMoment() ||\n (notification.isDismissedMoment() &&\n notification.getDismissedReason() !== 'credential_returned')\n ) {\n settle({\n authorized: false,\n moment: {\n momentType: notification.getMomentType(),\n skipped: notification.isSkippedMoment(),\n dismissed: notification.isDismissedMoment(),\n dismissedReason: notification.getDismissedReason(),\n },\n });\n }\n });\n } catch {\n settle({ authorized: false, unsupported: true, reason: 'prompt_error' });\n }\n });\n}\n\nexport type CodeProps = {\n client_id: string;\n /**\n * Space-delimited OAuth scopes. Defaults to OpenID Connect scopes so the\n * backend can exchange the code for an ID token, mirroring One Tap's intent.\n */\n scope?: string;\n /** 'popup' resolves the returned promise; 'redirect' navigates away and never resolves. */\n ux_mode?: 'popup' | 'redirect';\n /** Required when ux_mode is 'redirect'; for 'popup' Google uses postMessage. */\n redirect_uri?: string;\n state?: string;\n login_hint?: string;\n hd?: string;\n};\n\nexport type CodeResult =\n | { ok: true; response: CodeResponse }\n | { ok: false; error: ClientConfigError | CodeResponse };\n\n/**\n * OAuth 2.0 authorization-code fallback for environments where One Tap / FedCM\n * is unavailable (i.e. prompt() resolved with `unsupported: true`). It reuses\n * the same GSI script, so there is no extra dependency.\n *\n * Unlike One Tap it returns an authorization `code` for the backend to\n * exchange, not an ID token, and it must be triggered by a user gesture or the\n * popup may be blocked.\n */\nexport async function requestCode({\n client_id,\n scope = 'openid email profile',\n ux_mode = 'popup',\n redirect_uri,\n state,\n login_hint,\n hd,\n}: CodeProps): Promise<CodeResult> {\n await loadScript();\n\n return new Promise<CodeResult>((resolve) => {\n let settled = false;\n const settle = (result: CodeResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n const client = window.google.accounts.oauth2.initCodeClient({\n client_id,\n scope,\n ux_mode,\n redirect_uri,\n state,\n login_hint,\n hd,\n callback: (response) =>\n settle(response.code ? { ok: true, response } : { ok: false, error: response }),\n error_callback: (error) => settle({ ok: false, error }),\n });\n\n client.requestCode();\n });\n}\n"],"mappings":";AAkDA,IAAI,SAAmC;AAEvC,SAAS,aAA4B;AACnC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,QAAI,QAAQ;AACV,UAAI,OAAO,QAAQ,UAAU,IAAI;AAC/B,gBAAQ;AAAA,MACV,OAAO;AACL,eAAO,iBAAiB,QAAQ,MAAM,QAAQ,CAAC;AAC/C,eAAO;AAAA,UAAiB;AAAA,UAAS,MAC/B,OAAO,IAAI,MAAM,sCAAsC,CAAC;AAAA,QAC1D;AAAA,MACF;AACA;AAAA,IACF;AAEA,aAAS,SAAS,cAAc,QAAQ;AACxC,WAAO,KAAK;AACZ,WAAO,QAAQ;AACf,WAAO,QAAQ;AACf,WAAO,MAAM;AACb,WAAO,SAAS,MAAM,QAAQ;AAC9B,WAAO,UAAU,MAAM,OAAO,IAAI,MAAM,sCAAsC,CAAC;AAE/E,aAAS,KAAK,YAAY,MAAM;AAAA,EAClC,CAAC;AACH;AAGA,SAAS,mBAA4B;AACnC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,aAAO,EAAE,YAAY,OAAO,aAAa,MAAM,QAAQ,eAAe,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACH;AA+BA,eAAsB,YAAY;AAAA,EAChC;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,QAAM,WAAW;AAEjB,SAAO,IAAI,QAAoB,CAAC,YAAY;AAC1C,QAAI,UAAU;AACd,UAAM,SAAS,CAAC,WAAuB;AACrC,UAAI,QAAS;AACb,gBAAU;AACV,cAAQ,MAAM;AAAA,IAChB;AAEA,UAAM,SAAS,OAAO,OAAO,SAAS,OAAO,eAAe;AAAA,MAC1D;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,CAAC,aACT,OAAO,SAAS,OAAO,EAAE,IAAI,MAAM,SAAS,IAAI,EAAE,IAAI,OAAO,OAAO,SAAS,CAAC;AAAA,MAChF,gBAAgB,CAAC,UAAU,OAAO,EAAE,IAAI,OAAO,MAAM,CAAC;AAAA,IACxD,CAAC;AAED,WAAO,YAAY;AAAA,EACrB,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type {\n ClientConfigError,\n CodeResponse,\n CredentialResponse,\n GoogleAccounts,\n PromptMomentNotification,\n} from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n /**\n * Opaque nonce string forwarded as-is to Google. Google echoes it back in\n * the ID Token's `nonce` claim per the OIDC spec; the caller is responsible\n * for any hashing/encoding required by its verifier.\n */\n nonce?: string;\n client_id: string;\n auto_select?: boolean;\n cancel_on_tap_outside?: boolean;\n use_fedcm_for_prompt?: boolean;\n};\n\nexport type PromptMoment = {\n skipped: boolean;\n dismissed: boolean;\n dismissedReason: ReturnType<PromptMomentNotification['getDismissedReason']>;\n};\n\n/**\n * Why prompt() could not run One Tap, so the caller can decide to fall back\n * to requestCode().\n * - `fedcm_unsupported`: browser has no FedCM (Safari/Firefox/pre-117 Chrome).\n * - `script_load_failed`: the GSI script failed to load (network/CSP).\n * - `prompt_error`: GIS threw synchronously while initializing/prompting.\n */\nexport type UnsupportedReason = 'fedcm_unsupported' | 'script_load_failed' | 'prompt_error';\n\nexport type PromptResult =\n | { authorized: true; credential: CredentialResponse }\n | { authorized: false; moment: PromptMoment }\n | { authorized: false; unsupported: true; reason: UnsupportedReason };\n\nlet script: HTMLScriptElement | null = null;\n\nfunction loadScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n if (script) {\n if (window.google?.accounts?.id) {\n resolve();\n } else {\n script.addEventListener('load', () => resolve());\n script.addEventListener('error', () => {\n script = null; // allow a later call to recreate the element instead of hanging\n reject(new Error('Failed to load Google One Tap script'));\n });\n }\n return;\n }\n\n script = document.createElement('script');\n script.id = 'google-one-tap';\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => resolve();\n script.onerror = () => {\n script = null; // allow a later call to recreate the element instead of hanging\n reject(new Error('Failed to load Google One Tap script'));\n };\n\n document.head.appendChild(script);\n });\n}\n\n/** FedCM feature detection — `IdentityCredential` is absent on Safari, Firefox and pre-117 Chrome. */\nfunction isFedcmSupported(): boolean {\n return typeof window !== 'undefined' && 'IdentityCredential' in window;\n}\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport async function prompt({\n nonce,\n client_id,\n auto_select = false,\n use_fedcm_for_prompt = true,\n cancel_on_tap_outside = false,\n}: Props): Promise<PromptResult> {\n // FedCM is mandatory for One Tap on capable browsers (GIS completed the\n // migration in early 2025) and there is no viable legacy fallback anymore.\n // When the caller wants FedCM but the browser lacks it, bail early instead\n // of letting GIS throw an async `NotSupportedError: Missing request type`\n // from navigator.credentials.get. Callers should fall back to requestCode().\n if (use_fedcm_for_prompt !== false && !isFedcmSupported()) {\n return { authorized: false, unsupported: true, reason: 'fedcm_unsupported' };\n }\n\n try {\n await loadScript();\n } catch {\n return { authorized: false, unsupported: true, reason: 'script_load_failed' };\n }\n\n return new Promise<PromptResult>((resolve) => {\n let settled = false;\n const settle = (result: PromptResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n try {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select,\n nonce,\n client_id,\n use_fedcm_for_prompt,\n cancel_on_tap_outside,\n callback: (credential) => settle({ authorized: true, credential }),\n native_callback: (credential) => settle({ authorized: true, credential }),\n });\n\n window.google.accounts.id.prompt((notification) => {\n if (settled) return;\n\n const skipped = notification.isSkippedMoment();\n const dismissed = notification.isDismissedMoment();\n const dismissedReason = notification.getDismissedReason();\n\n if (skipped || (dismissed && dismissedReason !== 'credential_returned')) {\n settle({\n authorized: false,\n moment: { skipped, dismissed, dismissedReason },\n });\n }\n });\n } catch {\n settle({ authorized: false, unsupported: true, reason: 'prompt_error' });\n }\n });\n}\n\nexport type CodeProps = {\n client_id: string;\n /**\n * Space-delimited OAuth scopes. Defaults to OpenID Connect scopes so the\n * backend can exchange the code for an ID token, mirroring One Tap's intent.\n */\n scope?: string;\n /** 'popup' resolves the returned promise; 'redirect' navigates away and never resolves. */\n ux_mode?: 'popup' | 'redirect';\n /** Required when ux_mode is 'redirect'; for 'popup' Google uses postMessage. */\n redirect_uri?: string;\n state?: string;\n login_hint?: string;\n hd?: string;\n};\n\nexport type CodeResult =\n | { ok: true; response: CodeResponse }\n | { ok: false; error: ClientConfigError | CodeResponse };\n\n/**\n * OAuth 2.0 authorization-code fallback for environments where One Tap / FedCM\n * is unavailable (i.e. prompt() resolved with `unsupported: true`). It reuses\n * the same GSI script, so there is no extra dependency.\n *\n * Unlike One Tap it returns an authorization `code` for the backend to\n * exchange, not an ID token, and it must be triggered by a user gesture or the\n * popup may be blocked.\n */\nexport async function requestCode({\n client_id,\n scope = 'openid email profile',\n ux_mode = 'popup',\n redirect_uri,\n state,\n login_hint,\n hd,\n}: CodeProps): Promise<CodeResult> {\n await loadScript();\n\n return new Promise<CodeResult>((resolve) => {\n let settled = false;\n const settle = (result: CodeResult) => {\n if (settled) return;\n settled = true;\n resolve(result);\n };\n\n const client = window.google.accounts.oauth2.initCodeClient({\n client_id,\n scope,\n ux_mode,\n redirect_uri,\n state,\n login_hint,\n hd,\n callback: (response) =>\n settle(response.code ? { ok: true, response } : { ok: false, error: response }),\n error_callback: (error) => settle({ ok: false, error }),\n });\n\n client.requestCode();\n });\n}\n"],"mappings":";AAiDA,IAAI,SAAmC;AAEvC,SAAS,aAA4B;AACnC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,QAAI,QAAQ;AACV,UAAI,OAAO,QAAQ,UAAU,IAAI;AAC/B,gBAAQ;AAAA,MACV,OAAO;AACL,eAAO,iBAAiB,QAAQ,MAAM,QAAQ,CAAC;AAC/C,eAAO,iBAAiB,SAAS,MAAM;AACrC,mBAAS;AACT,iBAAO,IAAI,MAAM,sCAAsC,CAAC;AAAA,QAC1D,CAAC;AAAA,MACH;AACA;AAAA,IACF;AAEA,aAAS,SAAS,cAAc,QAAQ;AACxC,WAAO,KAAK;AACZ,WAAO,QAAQ;AACf,WAAO,QAAQ;AACf,WAAO,MAAM;AACb,WAAO,SAAS,MAAM,QAAQ;AAC9B,WAAO,UAAU,MAAM;AACrB,eAAS;AACT,aAAO,IAAI,MAAM,sCAAsC,CAAC;AAAA,IAC1D;AAEA,aAAS,KAAK,YAAY,MAAM;AAAA,EAClC,CAAC;AACH;AAGA,SAAS,mBAA4B;AACnC,SAAO,OAAO,WAAW,eAAe,wBAAwB;AAClE;AAGA,eAAsB,OAAO;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,wBAAwB;AAC1B,GAAiC;AAM/B,MAAI,yBAAyB,SAAS,CAAC,iBAAiB,GAAG;AACzD,WAAO,EAAE,YAAY,OAAO,aAAa,MAAM,QAAQ,oBAAo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,WAAuB;AACrC,UAAI,QAAS;AACb,gBAAU;AACV,cAAQ,MAAM;AAAA,IAChB;AAEA,UAAM,SAAS,OAAO,OAAO,SAAS,OAAO,eAAe;AAAA,MAC1D;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,CAAC,aACT,OAAO,SAAS,OAAO,EAAE,IAAI,MAAM,SAAS,IAAI,EAAE,IAAI,OAAO,OAAO,SAAS,CAAC;AAAA,MAChF,gBAAgB,CAAC,UAAU,OAAO,EAAE,IAAI,OAAO,MAAM,CAAC;AAAA,IACxD,CAAC;AAED,WAAO,YAAY;AAAA,EACrB,CAAC;AACH;","names":[]}
@@ -126,4 +126,4 @@ declare namespace index {
126
126
  export { index_AAID as AAID, index_ADVERTISING_ID as ADVERTISING_ID, index_ANDROID_ID as ANDROID_ID, index_COUNTRY_CODE as COUNTRY_CODE, index_COUNTRY_CODE_ALPHA_2 as COUNTRY_CODE_ALPHA_2, index_COUNTRY_CODE_ALPHA_3 as COUNTRY_CODE_ALPHA_3, index_DEVICE_ID as DEVICE_ID, index_EMAIL as EMAIL, index_EMAIL_DOMAIN as EMAIL_DOMAIN, index_EMAIL_LOCAL_PART as EMAIL_LOCAL_PART, index_IDFA as IDFA, index_IDFV as IDFV, index_IP as IP, index_IPv4 as IPv4, index_IPv4_MAPPED_IPv6 as IPv4_MAPPED_IPv6, index_IPv6 as IPv6, index_LANGUAGE_CODE as LANGUAGE_CODE, index_PHONE_NUMBER as PHONE_NUMBER, index_TIMEZONE as TIMEZONE, index_TIMEZONE_LONGEST as TIMEZONE_LONGEST, index_UDID as UDID, index_UUID as UUID };
127
127
  }
128
128
 
129
- export { ANDROID_ID as A, COUNTRY_CODE_ALPHA_2 as C, DEVICE_ID as D, EMAIL_LOCAL_PART as E, IDFV as I, LANGUAGE_CODE as L, PHONE_NUMBER as P, TIMEZONE_LONGEST as T, UUID as U, UDID as a, IDFA as b, AAID as c, ADVERTISING_ID as d, IPv4 as e, IPv6 as f, IPv4_MAPPED_IPv6 as g, IP as h, index as i, TIMEZONE as j, COUNTRY_CODE_ALPHA_3 as k, COUNTRY_CODE as l, EMAIL_DOMAIN as m, EMAIL as n };
129
+ export { AAID as A, COUNTRY_CODE as C, DEVICE_ID as D, EMAIL as E, IDFA as I, LANGUAGE_CODE as L, PHONE_NUMBER as P, TIMEZONE as T, UDID as U, ADVERTISING_ID as a, ANDROID_ID as b, COUNTRY_CODE_ALPHA_2 as c, COUNTRY_CODE_ALPHA_3 as d, EMAIL_DOMAIN as e, EMAIL_LOCAL_PART as f, IDFV as g, IP as h, IPv4 as i, IPv4_MAPPED_IPv6 as j, IPv6 as k, TIMEZONE_LONGEST as l, UUID as m, index as n };
@@ -126,4 +126,4 @@ declare namespace index {
126
126
  export { index_AAID as AAID, index_ADVERTISING_ID as ADVERTISING_ID, index_ANDROID_ID as ANDROID_ID, index_COUNTRY_CODE as COUNTRY_CODE, index_COUNTRY_CODE_ALPHA_2 as COUNTRY_CODE_ALPHA_2, index_COUNTRY_CODE_ALPHA_3 as COUNTRY_CODE_ALPHA_3, index_DEVICE_ID as DEVICE_ID, index_EMAIL as EMAIL, index_EMAIL_DOMAIN as EMAIL_DOMAIN, index_EMAIL_LOCAL_PART as EMAIL_LOCAL_PART, index_IDFA as IDFA, index_IDFV as IDFV, index_IP as IP, index_IPv4 as IPv4, index_IPv4_MAPPED_IPv6 as IPv4_MAPPED_IPv6, index_IPv6 as IPv6, index_LANGUAGE_CODE as LANGUAGE_CODE, index_PHONE_NUMBER as PHONE_NUMBER, index_TIMEZONE as TIMEZONE, index_TIMEZONE_LONGEST as TIMEZONE_LONGEST, index_UDID as UDID, index_UUID as UUID };
127
127
  }
128
128
 
129
- export { ANDROID_ID as A, COUNTRY_CODE_ALPHA_2 as C, DEVICE_ID as D, EMAIL_LOCAL_PART as E, IDFV as I, LANGUAGE_CODE as L, PHONE_NUMBER as P, TIMEZONE_LONGEST as T, UUID as U, UDID as a, IDFA as b, AAID as c, ADVERTISING_ID as d, IPv4 as e, IPv6 as f, IPv4_MAPPED_IPv6 as g, IP as h, index as i, TIMEZONE as j, COUNTRY_CODE_ALPHA_3 as k, COUNTRY_CODE as l, EMAIL_DOMAIN as m, EMAIL as n };
129
+ export { AAID as A, COUNTRY_CODE as C, DEVICE_ID as D, EMAIL as E, IDFA as I, LANGUAGE_CODE as L, PHONE_NUMBER as P, TIMEZONE as T, UDID as U, ADVERTISING_ID as a, ANDROID_ID as b, COUNTRY_CODE_ALPHA_2 as c, COUNTRY_CODE_ALPHA_3 as d, EMAIL_DOMAIN as e, EMAIL_LOCAL_PART as f, IDFV as g, IP as h, IPv4 as i, IPv4_MAPPED_IPv6 as j, IPv6 as k, TIMEZONE_LONGEST as l, UUID as m, index as n };
package/dist/index.d.cts CHANGED
@@ -5,7 +5,7 @@ export { ErrorBody, Status, StatusError } from './error/status.cjs';
5
5
  export { getErrorInfo, getErrorMessage, getFieldViolations } from './error/parse.cjs';
6
6
  export { Cursor, Empty, Entity, EntityId, InfinitePageData, InitParams, Items, NextParams, Page, PageParams, Pages, ParentPageParams, PrevParams, Response, getNextPageParam, getPreviousPageParam, initialPageParam, pageParamsSchema } from './response.cjs';
7
7
  export { UidGenerator, uid } from './snowflake.cjs';
8
- export { i as MAX_LENGTH } from './index-BnPgRQDl.cjs';
8
+ export { n as MAX_LENGTH } from './index-BhgdyigB.cjs';
9
9
  export { timing } from './utils/timing.cjs';
10
10
  export { forwardToGoogleTagGateway } from './utils/google-tag-gateway.cjs';
11
11
  export { ISO3166CountryCode, ISO_3601_1 } from './iso/iso_3601_1.cjs';
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { ErrorBody, Status, StatusError } from './error/status.js';
5
5
  export { getErrorInfo, getErrorMessage, getFieldViolations } from './error/parse.js';
6
6
  export { Cursor, Empty, Entity, EntityId, InfinitePageData, InitParams, Items, NextParams, Page, PageParams, Pages, ParentPageParams, PrevParams, Response, getNextPageParam, getPreviousPageParam, initialPageParam, pageParamsSchema } from './response.js';
7
7
  export { UidGenerator, uid } from './snowflake.js';
8
- export { i as MAX_LENGTH } from './index-BnPgRQDl.js';
8
+ export { n as MAX_LENGTH } from './index-BhgdyigB.js';
9
9
  export { timing } from './utils/timing.js';
10
10
  export { forwardToGoogleTagGateway } from './utils/google-tag-gateway.js';
11
11
  export { ISO3166CountryCode, ISO_3601_1 } from './iso/iso_3601_1.js';
@@ -1 +1 @@
1
- export { c as AAID, d as ADVERTISING_ID, A as ANDROID_ID, l as COUNTRY_CODE, C as COUNTRY_CODE_ALPHA_2, k as COUNTRY_CODE_ALPHA_3, D as DEVICE_ID, n as EMAIL, m as EMAIL_DOMAIN, E as EMAIL_LOCAL_PART, b as IDFA, I as IDFV, h as IP, e as IPv4, g as IPv4_MAPPED_IPv6, f as IPv6, L as LANGUAGE_CODE, P as PHONE_NUMBER, j as TIMEZONE, T as TIMEZONE_LONGEST, a as UDID, U as UUID } from '../index-BnPgRQDl.cjs';
1
+ export { A as AAID, a as ADVERTISING_ID, b as ANDROID_ID, C as COUNTRY_CODE, c as COUNTRY_CODE_ALPHA_2, d as COUNTRY_CODE_ALPHA_3, D as DEVICE_ID, E as EMAIL, e as EMAIL_DOMAIN, f as EMAIL_LOCAL_PART, I as IDFA, g as IDFV, h as IP, i as IPv4, j as IPv4_MAPPED_IPv6, k as IPv6, L as LANGUAGE_CODE, P as PHONE_NUMBER, T as TIMEZONE, l as TIMEZONE_LONGEST, U as UDID, m as UUID } from '../index-BhgdyigB.cjs';
@@ -1 +1 @@
1
- export { c as AAID, d as ADVERTISING_ID, A as ANDROID_ID, l as COUNTRY_CODE, C as COUNTRY_CODE_ALPHA_2, k as COUNTRY_CODE_ALPHA_3, D as DEVICE_ID, n as EMAIL, m as EMAIL_DOMAIN, E as EMAIL_LOCAL_PART, b as IDFA, I as IDFV, h as IP, e as IPv4, g as IPv4_MAPPED_IPv6, f as IPv6, L as LANGUAGE_CODE, P as PHONE_NUMBER, j as TIMEZONE, T as TIMEZONE_LONGEST, a as UDID, U as UUID } from '../index-BnPgRQDl.js';
1
+ export { A as AAID, a as ADVERTISING_ID, b as ANDROID_ID, C as COUNTRY_CODE, c as COUNTRY_CODE_ALPHA_2, d as COUNTRY_CODE_ALPHA_3, D as DEVICE_ID, E as EMAIL, e as EMAIL_DOMAIN, f as EMAIL_LOCAL_PART, I as IDFA, g as IDFV, h as IP, i as IPv4, j as IPv4_MAPPED_IPv6, k as IPv6, L as LANGUAGE_CODE, P as PHONE_NUMBER, T as TIMEZONE, l as TIMEZONE_LONGEST, U as UDID, m as UUID } from '../index-BhgdyigB.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/http",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,19 +38,19 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "vitest": "^4.1.5",
41
+ "vitest": "^4.1.7",
42
42
  "zod": "^4.4.3",
43
- "@shware/utils": "^1.4.2"
43
+ "@shware/utils": "^1.4.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^25",
47
- "@types/react": "^19.2.14",
47
+ "@types/react": "^19.2.15",
48
48
  "typescript": "^6.0.3",
49
49
  "@repo/typescript-config": "0.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "hono": "^4.12.16",
53
- "i18next": "^26.0.8",
52
+ "hono": "^4.12.23",
53
+ "i18next": "^26.3.0",
54
54
  "react": "^19"
55
55
  },
56
56
  "peerDependenciesMeta": {