@campnetwork/origin 0.0.1

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.
@@ -0,0 +1,194 @@
1
+ import React, { JSX } from 'react';
2
+ import { Auth } from '@campnetwork/sdk';
3
+ import { UseQueryResult } from '@tanstack/react-query';
4
+
5
+ /**
6
+ * CampContext
7
+ * @type {React.Context}
8
+ * @property {string} clientId The Camp client ID
9
+ * @property {Auth} auth The Camp Auth instance
10
+ * @property {function} setAuth The function to set the Camp Auth instance
11
+ * @property {boolean} wagmiAvailable Whether Wagmi is available
12
+ */
13
+ interface CampContextType {
14
+ clientId: string | null;
15
+ auth: Auth | null;
16
+ setAuth: React.Dispatch<React.SetStateAction<Auth>>;
17
+ wagmiAvailable: boolean;
18
+ ackee: any;
19
+ setAckee: any;
20
+ }
21
+ declare const CampContext: React.Context<CampContextType>;
22
+ /**
23
+ * CampProvider
24
+ * @param {Object} props The props
25
+ * @param {string} props.clientId The Camp client ID
26
+ * @param {string} props.redirectUri The redirect URI to use after social oauths
27
+ * @param {React.ReactNode} props.children The children components
28
+ * @param {boolean} props.allowAnalytics Whether to allow analytics to be sent
29
+ * @returns {JSX.Element} The CampProvider component
30
+ */
31
+ declare const CampProvider: ({ clientId, redirectUri, children, allowAnalytics, }: {
32
+ clientId: string;
33
+ redirectUri?: string;
34
+ children: React.ReactNode;
35
+ allowAnalytics?: boolean;
36
+ }) => React.JSX.Element;
37
+
38
+ interface ModalContextProps {
39
+ isButtonDisabled: boolean;
40
+ setIsButtonDisabled: (isButtonDisabled: boolean) => void;
41
+ isVisible: boolean;
42
+ setIsVisible: (isVisible: boolean) => void;
43
+ isLinkingVisible: boolean;
44
+ setIsLinkingVisible: (isLinkingVisible: boolean) => void;
45
+ currentlyLinking: any;
46
+ setCurrentlyLinking: (currentlyLinking: any) => void;
47
+ }
48
+ declare const ModalContext: React.Context<ModalContextProps>;
49
+
50
+ interface Provider {
51
+ info: {
52
+ uuid: string;
53
+ };
54
+ provider: any;
55
+ }
56
+
57
+ interface CampModalProps {
58
+ injectButton?: boolean;
59
+ wcProjectId?: string;
60
+ onlyWagmi?: boolean;
61
+ defaultProvider?: any;
62
+ }
63
+ /**
64
+ * The CampModal component.
65
+ * @param { { injectButton?: boolean, wcProjectId?: string, onlyWagmi?: boolean, defaultProvider?: object } } props The props.
66
+ * @returns { JSX.Element } The CampModal component.
67
+ */
68
+ declare const CampModal: ({ injectButton, wcProjectId, onlyWagmi, defaultProvider, }: CampModalProps) => JSX.Element;
69
+ /**
70
+ * The MyCampModal component.
71
+ * @param { { wcProvider: object } } props The props.
72
+ * @returns { JSX.Element } The MyCampModal component.
73
+ */
74
+ declare const MyCampModal: ({ wcProvider, }: {
75
+ wcProvider: any;
76
+ }) => JSX.Element;
77
+
78
+ declare const StandaloneCampButton: () => JSX.Element | null;
79
+ interface LinkButtonProps {
80
+ variant?: "default" | "icon";
81
+ social: "twitter" | "spotify" | "discord" | "tiktok" | "telegram";
82
+ theme?: "default" | "camp";
83
+ }
84
+ /**
85
+ * The LinkButton component.
86
+ * A button that will open the modal to link or unlink a social account.
87
+ * @param { { variant: ("default"|"icon"), social: ("twitter"|"spotify"|"discord"), theme: ("default"|"camp") } } props The props.
88
+ * @returns { JSX.Element } The LinkButton component.
89
+ */
90
+ declare const LinkButton: ({ variant, social, theme, }: LinkButtonProps) => JSX.Element | null;
91
+
92
+ /**
93
+ * Returns the Auth instance provided by the context.
94
+ * @returns { Auth } The Auth instance provided by the context.
95
+ * @example
96
+ * const auth = useAuth();
97
+ * auth.connect();
98
+ */
99
+ declare const useAuth: () => Auth;
100
+ /**
101
+ * Returns the functions to link and unlink socials.
102
+ * @returns { { linkTwitter: function, unlinkTwitter: function, linkDiscord: function, unlinkDiscord: function, linkSpotify: function, unlinkSpotify: function } } The functions to link and unlink socials.
103
+ * @example
104
+ * const { linkTwitter, unlinkTwitter, linkDiscord, unlinkDiscord, linkSpotify, unlinkSpotify } = useLinkSocials();
105
+ * linkTwitter();
106
+ */
107
+ declare const useLinkSocials: () => Record<string, Function>;
108
+ /**
109
+ * Fetches the provider from the context and sets the provider in the auth instance.
110
+ * @returns { { provider: { provider: string, info: { name: string } }, setProvider: function } } The provider and a function to set the provider.
111
+ */
112
+ declare const useProvider: () => {
113
+ provider: {
114
+ provider: any;
115
+ info: {
116
+ name: string;
117
+ };
118
+ };
119
+ setProvider: (provider: any, info?: any) => void;
120
+ };
121
+ /**
122
+ * Returns the authenticated state and loading state.
123
+ * @returns { { authenticated: boolean, loading: boolean } } The authenticated state and loading state.
124
+ */
125
+ declare const useAuthState: () => {
126
+ authenticated: boolean;
127
+ loading: boolean;
128
+ };
129
+ declare const useViem: () => {
130
+ client: any;
131
+ };
132
+ /**
133
+ * Connects and disconnects the user.
134
+ * @returns { { connect: function, disconnect: function } } The connect and disconnect functions.
135
+ */
136
+ declare const useConnect: () => {
137
+ connect: () => Promise<{
138
+ success: boolean;
139
+ message: string;
140
+ walletAddress: string;
141
+ }>;
142
+ disconnect: () => Promise<void>;
143
+ };
144
+ /**
145
+ * Returns the array of providers.
146
+ * @returns { Array } The array of providers and the loading state.
147
+ */
148
+ declare const useProviders: () => Provider[];
149
+ /**
150
+ * Returns the modal state and functions to open and close the modal.
151
+ * @returns { { isOpen: boolean, openModal: function, closeModal: function } } The modal state and functions to open and close the modal.
152
+ */
153
+ declare const useModal: () => {
154
+ isOpen: boolean;
155
+ openModal: () => void;
156
+ closeModal: () => void;
157
+ };
158
+ /**
159
+ * Returns the functions to open and close the link modal.
160
+ * @returns { { isLinkingOpen: boolean, closeModal: function, handleOpen: function } } The link modal state and functions to open and close the modal.
161
+ */
162
+ declare const useLinkModal: () => Record<string, Function | boolean> & {
163
+ isLinkingOpen: boolean;
164
+ closeModal: () => void;
165
+ handleOpen: (social: string) => void;
166
+ };
167
+ type UseSocialsResult<TData = unknown, TError = Error> = UseQueryResult<TData, TError> & {
168
+ socials: Record<string, string>;
169
+ };
170
+ /**
171
+ * Fetches the socials linked to the user.
172
+ * @returns { { data: {}, socials: {}, error: Error, isLoading: boolean, refetch: () => {} } } react-query query object.
173
+ */
174
+ declare const useSocials: () => UseSocialsResult;
175
+ /**
176
+ * Fetches the Origin usage data and uploads data.
177
+ * @returns { usage: { data: any, isError: boolean, isLoading: boolean, refetch: () => void }, uploads: { data: any, isError: boolean, isLoading: boolean, refetch: () => void } } The Origin usage data and uploads data.
178
+ */
179
+ declare const useOrigin: () => {
180
+ stats: {
181
+ data: any;
182
+ isError: boolean;
183
+ isLoading: boolean;
184
+ refetch: () => void;
185
+ };
186
+ uploads: {
187
+ data: any[];
188
+ isError: boolean;
189
+ isLoading: boolean;
190
+ refetch: () => void;
191
+ };
192
+ };
193
+
194
+ export { StandaloneCampButton as CampButton, CampContext, CampModal, CampProvider, LinkButton, ModalContext, MyCampModal, useAuth, useAuthState, useConnect, useLinkModal, useLinkSocials, useModal, useOrigin, useProvider, useProviders, useSocials, useViem };