@erikey/react 0.2.1 → 0.2.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.
package/dist/index.js CHANGED
@@ -1717,12 +1717,29 @@ function createAuthClient2(config) {
1717
1717
  if (typeof prop === "symbol") {
1718
1718
  return client[prop];
1719
1719
  }
1720
+ const mergeHeaders = (args) => {
1721
+ const [data, ...rest] = args;
1722
+ if (!data || typeof data !== "object") return args;
1723
+ const existingHeaders = data.fetchOptions?.headers || {};
1724
+ const mergedData = {
1725
+ ...data,
1726
+ fetchOptions: {
1727
+ ...data.fetchOptions,
1728
+ headers: {
1729
+ "X-Project-Id": projectId,
1730
+ ...existingHeaders
1731
+ }
1732
+ }
1733
+ };
1734
+ return [mergedData, ...rest];
1735
+ };
1720
1736
  if (prop === "signIn") {
1721
1737
  return new Proxy(client.signIn, {
1722
1738
  get(_signInTarget, signInProp) {
1723
1739
  if (signInProp === "email") {
1724
1740
  return async (...args) => {
1725
- const result = await client.signIn.email(...args);
1741
+ const mergedArgs = mergeHeaders(args);
1742
+ const result = await client.signIn.email(...mergedArgs);
1726
1743
  const token = result.data?.token;
1727
1744
  if (token) {
1728
1745
  const session = {
@@ -1744,7 +1761,8 @@ function createAuthClient2(config) {
1744
1761
  get(_signUpTarget, signUpProp) {
1745
1762
  if (signUpProp === "email") {
1746
1763
  return async (...args) => {
1747
- const result = await client.signUp.email(...args);
1764
+ const mergedArgs = mergeHeaders(args);
1765
+ const result = await client.signUp.email(...mergedArgs);
1748
1766
  const token = result.data?.token;
1749
1767
  if (token) {
1750
1768
  const session = {