@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.mjs CHANGED
@@ -1691,12 +1691,29 @@ function createAuthClient2(config) {
1691
1691
  if (typeof prop === "symbol") {
1692
1692
  return client[prop];
1693
1693
  }
1694
+ const mergeHeaders = (args) => {
1695
+ const [data, ...rest] = args;
1696
+ if (!data || typeof data !== "object") return args;
1697
+ const existingHeaders = data.fetchOptions?.headers || {};
1698
+ const mergedData = {
1699
+ ...data,
1700
+ fetchOptions: {
1701
+ ...data.fetchOptions,
1702
+ headers: {
1703
+ "X-Project-Id": projectId,
1704
+ ...existingHeaders
1705
+ }
1706
+ }
1707
+ };
1708
+ return [mergedData, ...rest];
1709
+ };
1694
1710
  if (prop === "signIn") {
1695
1711
  return new Proxy(client.signIn, {
1696
1712
  get(_signInTarget, signInProp) {
1697
1713
  if (signInProp === "email") {
1698
1714
  return async (...args) => {
1699
- const result = await client.signIn.email(...args);
1715
+ const mergedArgs = mergeHeaders(args);
1716
+ const result = await client.signIn.email(...mergedArgs);
1700
1717
  const token = result.data?.token;
1701
1718
  if (token) {
1702
1719
  const session = {
@@ -1718,7 +1735,8 @@ function createAuthClient2(config) {
1718
1735
  get(_signUpTarget, signUpProp) {
1719
1736
  if (signUpProp === "email") {
1720
1737
  return async (...args) => {
1721
- const result = await client.signUp.email(...args);
1738
+ const mergedArgs = mergeHeaders(args);
1739
+ const result = await client.signUp.email(...mergedArgs);
1722
1740
  const token = result.data?.token;
1723
1741
  if (token) {
1724
1742
  const session = {