@mezo-org/passport 0.4.0-dev.2 → 0.4.0-dev.5

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.
Files changed (85) hide show
  1. package/dist/src/api/auth.d.ts +43 -15
  2. package/dist/src/api/auth.d.ts.map +1 -1
  3. package/dist/src/api/auth.js +23 -26
  4. package/dist/src/api/auth.js.map +1 -1
  5. package/dist/src/hooks/constants.d.ts +2 -3
  6. package/dist/src/hooks/constants.d.ts.map +1 -1
  7. package/dist/src/hooks/constants.js +3 -4
  8. package/dist/src/hooks/constants.js.map +1 -1
  9. package/dist/src/hooks/index.d.ts +1 -3
  10. package/dist/src/hooks/index.d.ts.map +1 -1
  11. package/dist/src/hooks/index.js +1 -3
  12. package/dist/src/hooks/index.js.map +1 -1
  13. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +163 -0
  14. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
  15. package/dist/src/hooks/useAuthenticateWithWallet.js +58 -0
  16. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
  17. package/dist/src/hooks/useCreateAccount.d.ts +126 -72
  18. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  19. package/dist/src/hooks/useCreateAccount.js +1 -6
  20. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  21. package/dist/src/hooks/useCreateSession.d.ts +45 -126
  22. package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
  23. package/dist/src/hooks/useCreateSession.js +3 -11
  24. package/dist/src/hooks/useCreateSession.js.map +1 -1
  25. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts +5 -0
  26. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -0
  27. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +34 -0
  28. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -0
  29. package/dist/src/hooks/useGetAccountByAddress.d.ts +3 -5
  30. package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
  31. package/dist/src/hooks/useGetAccountByAddress.js +3 -4
  32. package/dist/src/hooks/useGetAccountByAddress.js.map +1 -1
  33. package/dist/src/hooks/useGetAccountByMezoId.d.ts +3 -5
  34. package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
  35. package/dist/src/hooks/useGetAccountByMezoId.js +3 -4
  36. package/dist/src/hooks/useGetAccountByMezoId.js.map +1 -1
  37. package/dist/src/hooks/useGetCurrentAccount.d.ts +3 -11
  38. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  39. package/dist/src/hooks/useGetCurrentAccount.js +3 -3
  40. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  41. package/dist/src/hooks/useGetSession.d.ts +3 -20
  42. package/dist/src/hooks/useGetSession.d.ts.map +1 -1
  43. package/dist/src/hooks/useGetSession.js +2 -2
  44. package/dist/src/hooks/useGetSession.js.map +1 -1
  45. package/dist/src/hooks/useLinkAccount.d.ts +126 -72
  46. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  47. package/dist/src/hooks/useLinkAccount.js +2 -18
  48. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  49. package/dist/src/hooks/useSignInWithDiscord.d.ts +53 -134
  50. package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
  51. package/dist/src/hooks/useSignInWithDiscord.js +5 -19
  52. package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
  53. package/dist/src/hooks/useSignInWithWallet.d.ts +53 -134
  54. package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
  55. package/dist/src/hooks/useSignInWithWallet.js +5 -43
  56. package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
  57. package/dist/src/hooks/useSignOut.d.ts.map +1 -1
  58. package/dist/src/hooks/useSignOut.js +4 -2
  59. package/dist/src/hooks/useSignOut.js.map +1 -1
  60. package/dist/src/hooks/useSignUpWithWallet.d.ts +161 -0
  61. package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
  62. package/dist/src/hooks/useSignUpWithWallet.js +11 -0
  63. package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
  64. package/dist/src/hooks/useUpdateMezoId.d.ts +153 -99
  65. package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
  66. package/dist/src/hooks/useUpdateMezoId.js +1 -8
  67. package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/api/auth.ts +84 -52
  70. package/src/hooks/constants.ts +3 -4
  71. package/src/hooks/index.ts +1 -3
  72. package/src/hooks/useAuthenticateWithWallet.ts +81 -0
  73. package/src/hooks/useCreateAccount.ts +1 -6
  74. package/src/hooks/useCreateSession.ts +3 -10
  75. package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +46 -0
  76. package/src/hooks/useGetAccountByAddress.ts +11 -5
  77. package/src/hooks/useGetAccountByMezoId.ts +11 -5
  78. package/src/hooks/useGetCurrentAccount.ts +10 -4
  79. package/src/hooks/useGetSession.ts +10 -3
  80. package/src/hooks/useLinkAccount.ts +2 -27
  81. package/src/hooks/useSignInWithDiscord.ts +5 -23
  82. package/src/hooks/useSignInWithWallet.ts +6 -54
  83. package/src/hooks/useSignOut.ts +4 -2
  84. package/src/hooks/useSignUpWithWallet.ts +14 -0
  85. package/src/hooks/useUpdateMezoId.ts +1 -8
@@ -8,20 +8,39 @@ type AccountPublicData = {
8
8
  btcAddress: string;
9
9
  evmAddress: string;
10
10
  };
11
- type Account = {
11
+ type AuthUser = {
12
+ id: string;
12
13
  app_metadata: {
13
14
  provider: PassportIdentityProvider;
14
15
  providers: PassportIdentityProvider[];
15
16
  };
16
17
  user_metadata: AccountPublicData;
17
18
  };
19
+ type AuthProvider = "discord";
20
+ export type LinkedAccount = {
21
+ type: "wallet";
22
+ btcAddress?: string;
23
+ evmAddress: string;
24
+ } | {
25
+ type: AuthProvider;
26
+ name: string;
27
+ id: string;
28
+ avatarUrl: string;
29
+ };
30
+ type Account = {
31
+ mezoId: string;
32
+ hasModifiedMezoId: boolean;
33
+ linkedAccounts: LinkedAccount[];
34
+ authUser: AuthUser;
35
+ };
18
36
  type Session = {
19
- access_token: string;
20
- token_type: string;
21
- expires_in: number;
22
- expires_at: number;
23
- refresh_token: string;
24
- user: Account;
37
+ expiresIn: number;
38
+ expiresAt: number;
39
+ sessionLinks: {
40
+ _links: {
41
+ account: "/session/account";
42
+ };
43
+ };
25
44
  };
26
45
  type AuthenticationProviderRedirectResponse = {
27
46
  redirectTo: string;
@@ -36,6 +55,14 @@ export type CreateSessionRequest = WalletAccountCredentials | {
36
55
  };
37
56
  export type LinkAccountRequest = CreateSessionRequest;
38
57
  export type CreateAccountRequest = WalletAccountCredentials;
58
+ export type GetSessionResponse = Session | {
59
+ nonce: string;
60
+ };
61
+ export type GetCurrentAccountResponse = Partial<Account> | null;
62
+ export type GetAccountByMezoIdOrAddressResponse = {
63
+ mezoId?: string;
64
+ linkedAccounts?: LinkedAccount[];
65
+ };
39
66
  export declare const API_ENDPOINTS_BY_ENV: {
40
67
  mainnet: string;
41
68
  testnet: string;
@@ -47,27 +74,28 @@ export declare class AuthApiClient {
47
74
  * The request handler for the Passport API. It accepts an API endpoint and
48
75
  * request options.
49
76
  * @dev Generic type `D` is a type of returned object from the function
77
+ * @dev WARNING: This function hardcodes `credentials: "include"`, meaning
78
+ * cookies and authentication headers will be sent with every request. Ensure
79
+ * this is safe if you plan to use it in other contexts than auth api worker.
50
80
  * @param endpoint - The API endpoint to request. Should start with
51
81
  * forward slash ("/")
52
- * @param {RequestHandlerOptions<B>} options - The request options, the
53
- * `RequestInit` type with additional type-safe properties
82
+ * @param options - The request options, the `RequestInit` type with
83
+ * additional type-safe properties
54
84
  * @returns The promise of the API response
55
85
  */
56
86
  protected handleRequest<D>(endpoint: `/${string}`, options: RequestHandlerOptions): Promise<D>;
57
- getSession(code?: string): Promise<Session | {
58
- nonce: string;
59
- }>;
87
+ getSession(code?: string): Promise<GetSessionResponse>;
60
88
  createSession(createSessionRequest: CreateSessionRequest): Promise<Session | {
61
89
  redirectTo: string;
62
90
  }>;
63
91
  deleteSession(): Promise<{
64
92
  message: string;
65
93
  }>;
66
- getCurrentAccount(): Promise<Account>;
67
- getAccountByMezoIdOrAddress(mezoIdOrAddress: string): Promise<AccountPublicData>;
94
+ getCurrentAccount(): Promise<GetCurrentAccountResponse>;
95
+ getAccountByMezoIdOrAddress(mezoIdOrAddress: string): Promise<GetAccountByMezoIdOrAddressResponse>;
68
96
  linkAccount(linkAccountRequest: LinkAccountRequest): Promise<Account | AuthenticationProviderRedirectResponse>;
69
97
  createAccount(createAccountRequest: CreateAccountRequest): Promise<Account>;
70
- updateMezoId(newMezoId: string): Promise<Account>;
98
+ updateMezoId(newMezoId: string): Promise<Partial<Account> | null>;
71
99
  }
72
100
  export {};
73
101
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/api/auth.ts"],"names":[],"mappings":"AAAA,KAAK,qBAAqB,GAAG,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,MAAM,CAAC,GAAG;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACjD,CAAA;AACD,KAAK,wBAAwB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9D,KAAK,iBAAiB,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,OAAO,GAAG;IACb,YAAY,EAAE;QACZ,QAAQ,EAAE,wBAAwB,CAAA;QAClC,SAAS,EAAE,wBAAwB,EAAE,CAAA;KACtC,CAAA;IACD,aAAa,EAAE,iBAAiB,CAAA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AAE,kBAAkB;IAWlD,aAAa,CAAC,oBAAoB,EAAE,oBAAoB;IASxD,YAAY,CAAC,SAAS,EAAE,MAAM;CAWrC"}
@@ -2,20 +2,22 @@ export const API_ENDPOINTS_BY_ENV = {
2
2
  mainnet: "https://api.mezo.org",
3
3
  testnet: "https://api.test.mezo.org",
4
4
  };
5
- const DEFAULT_API_ENDPOINT = API_ENDPOINTS_BY_ENV.mainnet;
6
5
  export class AuthApiClient {
7
6
  apiUrl;
8
7
  constructor(apiUrl) {
9
- this.apiUrl = apiUrl ?? DEFAULT_API_ENDPOINT;
8
+ this.apiUrl = apiUrl ?? API_ENDPOINTS_BY_ENV.mainnet;
10
9
  }
11
10
  /**
12
11
  * The request handler for the Passport API. It accepts an API endpoint and
13
12
  * request options.
14
13
  * @dev Generic type `D` is a type of returned object from the function
14
+ * @dev WARNING: This function hardcodes `credentials: "include"`, meaning
15
+ * cookies and authentication headers will be sent with every request. Ensure
16
+ * this is safe if you plan to use it in other contexts than auth api worker.
15
17
  * @param endpoint - The API endpoint to request. Should start with
16
18
  * forward slash ("/")
17
- * @param {RequestHandlerOptions<B>} options - The request options, the
18
- * `RequestInit` type with additional type-safe properties
19
+ * @param options - The request options, the `RequestInit` type with
20
+ * additional type-safe properties
19
21
  * @returns The promise of the API response
20
22
  */
21
23
  async handleRequest(endpoint, options) {
@@ -28,28 +30,23 @@ export class AuthApiClient {
28
30
  Object.entries(queryParams)
29
31
  .filter(([, value]) => value) // Remove falsy values
30
32
  .forEach(([key, value]) => url.searchParams.append(key, value));
31
- try {
32
- const response = await fetch(url, {
33
- method,
34
- credentials: "include",
35
- headers: {
36
- "Content-Type": "application/json",
37
- ...headers,
38
- },
39
- body: body ? JSON.stringify(body) : undefined,
40
- ...restOptions,
41
- });
42
- const data = await response.json();
43
- if (!response.ok || data?.error) {
44
- const error = data?.error || "An error occurred";
45
- throw new Error(error);
46
- }
47
- return data;
48
- }
49
- catch (error) {
50
- const errorMessage = error instanceof Error ? error.message : "An error occurred";
51
- throw new Error(errorMessage);
33
+ const response = await fetch(url, {
34
+ method,
35
+ credentials: "include",
36
+ headers: {
37
+ "Content-Type": "application/json",
38
+ ...headers,
39
+ },
40
+ body: body ? JSON.stringify(body) : undefined,
41
+ ...restOptions,
42
+ });
43
+ const data = await response.json();
44
+ if (!response.ok || data?.error) {
45
+ const error = data?.error ||
46
+ `An error occurred when handling API request: ${JSON.stringify(data)}`;
47
+ throw new Error(`Error [${response.status}]: ${error}`);
52
48
  }
49
+ return data;
53
50
  }
54
51
  async getSession(code) {
55
52
  const data = await this.handleRequest("/session", {
@@ -100,7 +97,7 @@ export class AuthApiClient {
100
97
  async updateMezoId(newMezoId) {
101
98
  const data = await this.handleRequest("/session/account", {
102
99
  method: "PATCH",
103
- body: { newMezoId },
100
+ body: { mezoId: newMezoId },
104
101
  });
105
102
  return data;
106
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/api/auth.ts"],"names":[],"mappings":"AA+CA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EAAE,2BAA2B;CACrC,CAAA;AAED,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,OAAO,CAAA;AAEzD,MAAM,OAAO,aAAa;IAChB,MAAM,CAAQ;IAEtB,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,oBAAoB,CAAA;IAC9C,CAAC;IAED;;;;;;;;;OASG;IACO,KAAK,CAAC,aAAa,CAC3B,QAAsB,EACtB,OAA8B;QAE9B,MAAM,EACJ,MAAM,EACN,OAAO,EACP,IAAI,EACJ,WAAW,GAAG,EAAE,EAChB,GAAG,WAAW,EACf,GAAG,OAAO,IAAI,EAAE,CAAA;QAEjB,kEAAkE;QAClE,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QACtD,MAAM,GAAG,GAAG,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+ ACCOUNT: string;
4
3
  SESSION: string;
5
- CURRENT_ACCOUNT: string;
4
+ CURRENT: string;
6
5
  };
7
6
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;CAKtB,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;CAItB,CAAA"}
@@ -1,7 +1,6 @@
1
1
  export const QUERY_KEYS = {
2
- ACCOUNT_BY_ADDRESS: "getAccountByAddress",
3
- ACCOUNT_BY_MEZO_ID: "getAccountByMezoId",
4
- SESSION: "getSession",
5
- CURRENT_ACCOUNT: "getCurrentAccount",
2
+ ACCOUNT: "account",
3
+ SESSION: "session",
4
+ CURRENT: "current",
6
5
  };
7
6
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,kBAAkB,EAAE,qBAAqB;IACzC,kBAAkB,EAAE,oBAAoB;IACxC,OAAO,EAAE,YAAY;IACrB,eAAe,EAAE,mBAAmB;CACrC,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;CACnB,CAAA"}
@@ -1,15 +1,13 @@
1
1
  export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
2
- export * from "./constants";
3
- export * from "./useAuthApiClient";
4
2
  export * from "./useCreateAccount";
5
3
  export * from "./useGetAccountByAddress";
6
4
  export * from "./useGetAccountByMezoId";
7
5
  export * from "./useGetCurrentAccount";
8
6
  export * from "./useGetSession";
9
7
  export * from "./useLinkAccount";
10
- export * from "./usePassportContext";
11
8
  export * from "./useSignInWithDiscord";
12
9
  export * from "./useSignInWithWallet";
13
10
  export * from "./useSignOut";
11
+ export * from "./useSignUpWithWallet";
14
12
  export * from "./useUpdateMezoId";
15
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA"}
@@ -1,15 +1,13 @@
1
1
  export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
2
- export * from "./constants";
3
- export * from "./useAuthApiClient";
4
2
  export * from "./useCreateAccount";
5
3
  export * from "./useGetAccountByAddress";
6
4
  export * from "./useGetAccountByMezoId";
7
5
  export * from "./useGetCurrentAccount";
8
6
  export * from "./useGetSession";
9
7
  export * from "./useLinkAccount";
10
- export * from "./usePassportContext";
11
8
  export * from "./useSignInWithDiscord";
12
9
  export * from "./useSignInWithWallet";
13
10
  export * from "./useSignOut";
11
+ export * from "./useSignUpWithWallet";
14
12
  export * from "./useUpdateMezoId";
15
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,163 @@
1
+ declare function useAuthenticateWithWallet({ signUp, }?: {
2
+ signUp?: boolean;
3
+ }): {
4
+ data: undefined;
5
+ variables: undefined;
6
+ error: null;
7
+ isError: false;
8
+ isIdle: true;
9
+ isPending: false;
10
+ isSuccess: false;
11
+ status: "idle";
12
+ reset: () => void;
13
+ context: unknown;
14
+ failureCount: number;
15
+ failureReason: Error | null;
16
+ isPaused: boolean;
17
+ submittedAt: number;
18
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
19
+ expiresIn: number;
20
+ expiresAt: number;
21
+ sessionLinks: {
22
+ _links: {
23
+ account: "/session/account";
24
+ };
25
+ };
26
+ } | {
27
+ redirectTo: string;
28
+ }, Error, void, unknown>;
29
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
30
+ expiresIn: number;
31
+ expiresAt: number;
32
+ sessionLinks: {
33
+ _links: {
34
+ account: "/session/account";
35
+ };
36
+ };
37
+ } | {
38
+ redirectTo: string;
39
+ }, Error, void, unknown>;
40
+ } | {
41
+ data: undefined;
42
+ variables: void;
43
+ error: null;
44
+ isError: false;
45
+ isIdle: false;
46
+ isPending: true;
47
+ isSuccess: false;
48
+ status: "pending";
49
+ reset: () => void;
50
+ context: unknown;
51
+ failureCount: number;
52
+ failureReason: Error | null;
53
+ isPaused: boolean;
54
+ submittedAt: number;
55
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
56
+ expiresIn: number;
57
+ expiresAt: number;
58
+ sessionLinks: {
59
+ _links: {
60
+ account: "/session/account";
61
+ };
62
+ };
63
+ } | {
64
+ redirectTo: string;
65
+ }, Error, void, unknown>;
66
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
67
+ expiresIn: number;
68
+ expiresAt: number;
69
+ sessionLinks: {
70
+ _links: {
71
+ account: "/session/account";
72
+ };
73
+ };
74
+ } | {
75
+ redirectTo: string;
76
+ }, Error, void, unknown>;
77
+ } | {
78
+ data: undefined;
79
+ error: Error;
80
+ variables: void;
81
+ isError: true;
82
+ isIdle: false;
83
+ isPending: false;
84
+ isSuccess: false;
85
+ status: "error";
86
+ reset: () => void;
87
+ context: unknown;
88
+ failureCount: number;
89
+ failureReason: Error | null;
90
+ isPaused: boolean;
91
+ submittedAt: number;
92
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
93
+ expiresIn: number;
94
+ expiresAt: number;
95
+ sessionLinks: {
96
+ _links: {
97
+ account: "/session/account";
98
+ };
99
+ };
100
+ } | {
101
+ redirectTo: string;
102
+ }, Error, void, unknown>;
103
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
104
+ expiresIn: number;
105
+ expiresAt: number;
106
+ sessionLinks: {
107
+ _links: {
108
+ account: "/session/account";
109
+ };
110
+ };
111
+ } | {
112
+ redirectTo: string;
113
+ }, Error, void, unknown>;
114
+ } | {
115
+ data: {
116
+ expiresIn: number;
117
+ expiresAt: number;
118
+ sessionLinks: {
119
+ _links: {
120
+ account: "/session/account";
121
+ };
122
+ };
123
+ } | {
124
+ redirectTo: string;
125
+ };
126
+ error: null;
127
+ variables: void;
128
+ isError: false;
129
+ isIdle: false;
130
+ isPending: false;
131
+ isSuccess: true;
132
+ status: "success";
133
+ reset: () => void;
134
+ context: unknown;
135
+ failureCount: number;
136
+ failureReason: Error | null;
137
+ isPaused: boolean;
138
+ submittedAt: number;
139
+ authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
140
+ expiresIn: number;
141
+ expiresAt: number;
142
+ sessionLinks: {
143
+ _links: {
144
+ account: "/session/account";
145
+ };
146
+ };
147
+ } | {
148
+ redirectTo: string;
149
+ }, Error, void, unknown>;
150
+ authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
151
+ expiresIn: number;
152
+ expiresAt: number;
153
+ sessionLinks: {
154
+ _links: {
155
+ account: "/session/account";
156
+ };
157
+ };
158
+ } | {
159
+ redirectTo: string;
160
+ }, Error, void, unknown>;
161
+ };
162
+ export { useAuthenticateWithWallet };
163
+ //# sourceMappingURL=useAuthenticateWithWallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAUA,iBAAS,yBAAyB,CAAC,EACjC,MAAc,GACf,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkE3B;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
@@ -0,0 +1,58 @@
1
+ import { useAccount, useSignMessage } from "wagmi";
2
+ import { useBitcoinAccount } from "@mezo-org/orangekit";
3
+ import { useMutation } from "@tanstack/react-query";
4
+ import { useMemo } from "react";
5
+ import { useCreateAccount } from "./useCreateAccount";
6
+ import { useCreateSession } from "./useCreateSession";
7
+ import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
8
+ import { createSignInWithWalletMessage } from "../utils/siww";
9
+ import { useGetAccountByAddress } from "./useGetAccountByAddress";
10
+ function useAuthenticateWithWallet({ signUp = false, } = {}) {
11
+ const { chainId, address, connector } = useAccount();
12
+ const { btcAddress } = useBitcoinAccount();
13
+ const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
14
+ const { createSessionAsync } = useCreateSession();
15
+ const { createAccountAsync } = useCreateAccount();
16
+ const { signMessageAsync } = useSignMessage();
17
+ const walletAddress = useMemo(() => (connector?.type === "orangekit" ? btcAddress : address), [btcAddress, address, connector]);
18
+ const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, { enabled: false, retry: false });
19
+ const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
20
+ mutationFn: async () => {
21
+ if (!address) {
22
+ throw new Error("Sign in error: Wallet not connected!");
23
+ }
24
+ const nonce = await ensureNoSessionAndFetchNonce();
25
+ const networkFamily = btcAddress ? "bitcoin" : "evm";
26
+ const messageResult = createSignInWithWalletMessage(btcAddress ? btcAddress : address, nonce, networkFamily, chainId);
27
+ const signatureResult = await signMessageAsync({
28
+ message: messageResult,
29
+ connector,
30
+ });
31
+ if (signUp) {
32
+ const getAcountByAddressResult = await getAccountByAddress();
33
+ if (!getAcountByAddressResult.data) {
34
+ const createAccountResult = await createAccountAsync({
35
+ type: "wallet",
36
+ message: messageResult,
37
+ signature: signatureResult,
38
+ });
39
+ if (!createAccountResult) {
40
+ throw new Error("Sign in error: Failed to create new account");
41
+ }
42
+ }
43
+ }
44
+ return createSessionAsync({
45
+ type: "wallet",
46
+ message: messageResult,
47
+ signature: signatureResult,
48
+ });
49
+ },
50
+ });
51
+ return {
52
+ authenticateWithWallet: mutate,
53
+ authenticateWithWalletAsync: mutateAsync,
54
+ ...signInMutationRestParameters,
55
+ };
56
+ }
57
+ export { useAuthenticateWithWallet };
58
+ //# sourceMappingURL=useAuthenticateWithWallet.js.map
@@ -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