Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ dist
docs/agent
docs/assets
docs/auth-client
docs/use-auth-client
docs/authentication
docs/identity
docs/identity-secp256k1
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- feat: management canister interface updates for schnorr signatures
- docs: documentation and metadata for use-auth-client

### Changed
- feat: replaces hdkey and bip32 implementations with `@scure/bip39` and `@scure/bip32` due to vulnerability and lack of maintenance for `elliptic`
Expand Down
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<a href="/principal/index.html">Principal</a>
<a href="/candid/index.html">Candid</a>
<a href="/auth-client/index.html">Auth-Client</a>
<a href="/use-auth-client/index.html">useAuthClient (React Hook)</a>
<a href="/assets/index.html">Asset Manager</a>
<a href="/identity/index.html">Identity</a>
<a href="/identity-secp256k1/index.html">Secp256k1 Identity</a>
Expand Down
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions packages/use-auth-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# @dfinity/use-auth-client

`@dfinity/use-auth-client`! This is a package for Internet Computer React developers, making it easier to integrate the auth-client with your React application.

You can use it to manage your identity for you, or you can pass it an `idlFactory` and `canisterId` and it will construct and manage your entire `Actor` for you.

To install, use
```
npm install @dfinity/use-auth-client
```

and you can import and set it up like so:

```
import {useAuthClient} from '@dfinity/use-auth-client';

...ts
const App = () => {
const identityProvider =
// eslint-disable-next-line no-undef
process.env.DFX_NETWORK === 'local'
? // eslint-disable-next-line no-undef
`http://${process.env.CANISTER_ID_INTERNET_IDENTITY}.localhost:4943`
: 'https://identity.ic0.app';

const { isAuthenticated, login, logout, actor } = useAuthClient({
loginOptions: {
identityProvider,
},
actorOptions: {
canisterId,
idlFactory,
},
});
...
}
```

There is a live demo at https://5ibdo-haaaa-aaaab-qajia-cai.icp0.io/

Additional generated documentaion is available at https://agent-js.icp.xyz/use-auth-client/index.html
35 changes: 32 additions & 3 deletions packages/use-auth-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,39 @@
"unpkg": "./lib/esm/index",
"scripts": {
"build": "tsc -b && tsc -p tsconfig-cjs.json",
"make:docs/reference": "typedoc src/index.ts --out ../../docs/use-auth-client --excludeInternal",
"test": "jest"
},
"keywords": [],
"author": "Kai Peacock",
"license": "ISC",
"keywords": [
"internet computer",
"internet-computer",
"ic",
"dfinity",
"agent",
"actor",
"dfx",
"canister",
"candid",
"motoko",
"javascript",
"typescript",
"blockchain",
"crypto",
"distributed",
"api",
"sdk"
],
"bugs": {
"url": "https://github.com/dfinity/agent-js/issues"
},
"author": "DFINITY Stiftung <sdk@dfinity.org>",
"license": "Apache-2.0",
"homepage": "https://internetcomputer.org",
"repository": {
"type": "git",
"url": "https://github.com/dfinity/agent-js.git",
"directory": "packages/use-auth-client"
},
"dependencies": {
"@dfinity/agent": "^2.0.0",
"@dfinity/auth-client": "^2.0.0",
Expand All @@ -32,6 +60,7 @@
"babel-jest": "^29.7.0",
"fake-indexeddb": "^6.0.0",
"jest": "^29.7.0",
"typedoc": "^0.26.5",
"vitest": "^2.0.5"
},
"optionalDependencies": {
Expand Down