From a45bdbf057a98628fbea7d208f67363275ea5c98 Mon Sep 17 00:00:00 2001 From: Kyle Peacock Date: Tue, 6 Aug 2024 12:39:41 -0700 Subject: [PATCH] docs: documentation and metadata for use-auth-client --- .gitignore | 1 + docs/CHANGELOG.md | 1 + docs/index.html | 1 + package-lock.json | 3 ++ packages/use-auth-client/README.md | 41 +++++++++++++++++++++++++++ packages/use-auth-client/package.json | 35 +++++++++++++++++++++-- 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 packages/use-auth-client/README.md diff --git a/.gitignore b/.gitignore index 07e24c76..6ea47b58 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,7 @@ dist docs/agent docs/assets docs/auth-client +docs/use-auth-client docs/authentication docs/identity docs/identity-secp256k1 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2a46f460..08eb35ef 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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` diff --git a/docs/index.html b/docs/index.html index 33941037..31f55f09 100644 --- a/docs/index.html +++ b/docs/index.html @@ -25,6 +25,7 @@ Principal Candid Auth-Client + useAuthClient (React Hook) Asset Manager Identity Secp256k1 Identity diff --git a/package-lock.json b/package-lock.json index 865b1b6b..c59fc595 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16189,6 +16189,8 @@ }, "node_modules/typedoc": { "version": "0.26.5", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz", + "integrity": "sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -19422,6 +19424,7 @@ "babel-jest": "^29.7.0", "fake-indexeddb": "^6.0.0", "jest": "^29.7.0", + "typedoc": "^0.26.5", "vitest": "^2.0.5" }, "optionalDependencies": { diff --git a/packages/use-auth-client/README.md b/packages/use-auth-client/README.md new file mode 100644 index 00000000..09533833 --- /dev/null +++ b/packages/use-auth-client/README.md @@ -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 diff --git a/packages/use-auth-client/package.json b/packages/use-auth-client/package.json index 1e37d80f..4799cfd0 100644 --- a/packages/use-auth-client/package.json +++ b/packages/use-auth-client/package.json @@ -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 ", + "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", @@ -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": {