@edgeandnode/graph-auth-kit 0.2.0 → 0.3.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.
- package/README.md +31 -0
- package/dist/Components/Connected.d.ts +29 -0
- package/dist/Components/Connected.d.ts.map +1 -0
- package/dist/Components/Disconnected.d.ts +28 -0
- package/dist/Components/Disconnected.d.ts.map +1 -0
- package/dist/Components/index.d.ts +3 -0
- package/dist/Components/index.d.ts.map +1 -0
- package/dist/client.d.ts +2541 -675
- package/dist/client.d.ts.map +1 -1
- package/dist/hooks.d.ts +19 -2
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -2
- package/dist/test-harness/index.js +1 -1
- package/package.json +12 -11
- package/dist/{GraphAuthKit.context-DBwb2jco.js → GraphAuthKit.context-B7OJAuEY.js} +30 -30
package/README.md
CHANGED
|
@@ -231,6 +231,37 @@ export function Layout({ children }: Readonly<{ children: ReactNode }>) {
|
|
|
231
231
|
- `useGraphAuthKitAccount` -> This is an override of the [wagmi useAccount hook](https://wagmi.sh/react/api/hooks/useAccount). The reason is, if the user connects with a multisig, the wagmi context is connected with the user-selected EoA, so all of the wagmi context hooks reference this EoA and not the Safe. This returns the wagmi `UseAccountReturnType` but the `address` and `addresses` values include the entered Safe address. It also adds an `eoa` property that is the connected EoA address.
|
|
232
232
|
- `useGraphAuthKitConnector` -> The user selected wallet/connector option.
|
|
233
233
|
|
|
234
|
+
## Components
|
|
235
|
+
|
|
236
|
+
- `Connected` -> renders the passed in `children` _only if_ the user is connected.
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import { Connected } from '@edgeandnode/graph-auth-kit'
|
|
240
|
+
|
|
241
|
+
export function ShowMeConnected() {
|
|
242
|
+
return <Connected>{(account) => <div>Connected Wallet: {account.address}</div>}</Connected>
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
- `Disconnected` -> renders the passed in `children` _only if_ the user id disconnected. Useful for rendering components like a "Connect Wallet" CTA that should only render if the user is _not_ authenticated.
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import { ExperimentalButton as Button } from '@edgeandnode/gds'
|
|
250
|
+
import { Disconnected, useGraphAuthKit } from '@edgeandnode/graph-auth-kit'
|
|
251
|
+
|
|
252
|
+
export function ShowMeDisconnected() {
|
|
253
|
+
const authkit = useGraphAuthKit()
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<Disconnected>
|
|
257
|
+
<Button variant="primary" onClick={() => authkit.openConnectModal()}>
|
|
258
|
+
Connect Wallet
|
|
259
|
+
</Button>
|
|
260
|
+
</Disconnected>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
234
265
|
## References
|
|
235
266
|
|
|
236
267
|
- [`wagmi`](https://wagmi.sh/)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type UseGraphAuthKitAccountReturnType } from '../hooks';
|
|
3
|
+
export type ConnectedProps = {
|
|
4
|
+
children(account: {
|
|
5
|
+
address: NonNullable<UseGraphAuthKitAccountReturnType['address']>;
|
|
6
|
+
chain: NonNullable<UseGraphAuthKitAccountReturnType['chain']>;
|
|
7
|
+
}): ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Utility component that only renders the passed in children if the user is authenticated.
|
|
11
|
+
* Otherwise, it renders null.
|
|
12
|
+
* Useful for wrapping components where you want to guarantee that they are only rendered,
|
|
13
|
+
* if the user is connected.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { Connected } from '@edgeandnode/graph-auth-kit'
|
|
18
|
+
*
|
|
19
|
+
* export function ShowMeConnected() {
|
|
20
|
+
* return (
|
|
21
|
+
* <Connected>
|
|
22
|
+
* {(account) => <div>Connected Wallet: {account.address}</div>}
|
|
23
|
+
* </Connected>
|
|
24
|
+
* )
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function Connected({ children }: ConnectedProps): ReactNode;
|
|
29
|
+
//# sourceMappingURL=Connected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connected.d.ts","sourceRoot":"","sources":["../../src/Components/Connected.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAA0B,KAAK,gCAAgC,EAAE,MAAM,UAAU,CAAA;AAExF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE;QAChB,OAAO,EAAE,WAAW,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAA;QACjE,KAAK,EAAE,WAAW,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAA;KAC9D,GAAG,SAAS,CAAA;CACd,CAAA;AACD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,cAAc,aAWrD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type DisconnectedProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Utility component that only renders the passed in children if the user is NOT connected/authenticated.
|
|
7
|
+
* If the user is connected, this will render null.
|
|
8
|
+
* Useful for wrapping components where you want to guarantee that they are only rendered,
|
|
9
|
+
* if the user is NOT connected.
|
|
10
|
+
* Such as: a connect wallet button, etc
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { Disconnected, useGraphAuthKit } from '@edgeandnode/graph-auth-kit'
|
|
15
|
+
*
|
|
16
|
+
* export function ShowMeDisonnected() {
|
|
17
|
+
* const authkit = useGraphAuthKit()
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <Disconnected>
|
|
21
|
+
* <button onClick={() => authkit.openConnectModal()}>Connect</button>
|
|
22
|
+
* </Disconnected>
|
|
23
|
+
* )
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function Disconnected({ children }: DisconnectedProps): ReactNode;
|
|
28
|
+
//# sourceMappingURL=Disconnected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Disconnected.d.ts","sourceRoot":"","sources":["../../src/Components/Disconnected.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,aAQ3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA"}
|