@ldclabs/ic-auth 0.1.2 → 0.1.3
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 +53 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,63 @@
|
|
|
1
|
-
#
|
|
2
|
-

|
|
3
3
|
[](https://github.com/ldclabs/ic-auth/actions/workflows/test.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@ldclabs/ic-auth)
|
|
5
5
|
|
|
6
6
|
[IC-Auth](https://github.com/ldclabs/ic-auth) is a comprehensive web authentication system based on the Internet Computer (ICP) identity.
|
|
7
7
|
|
|
8
|
-
`@ldclabs/ic-auth` is the
|
|
8
|
+
`@ldclabs/ic-auth` is the client-side TypeScript SDK for `ic-auth`, providing essential utilities for identity management and data serialization.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Install the package using your favorite package manager:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @ldclabs/ic-auth
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
or
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add @ldclabs/ic-auth
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This package has peer dependencies on several `@dfinity` packages, which you should also have in your project.
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@dfinity/candid": ">=3.2.0",
|
|
29
|
+
"@dfinity/agent": ">=3.2.0",
|
|
30
|
+
"@dfinity/identity": ">=3.2.0",
|
|
31
|
+
"@dfinity/principal": ">=3.2.0",
|
|
32
|
+
"@noble/hashes": ">=1.8.0",
|
|
33
|
+
"cborg": ">=4.2.0"
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
Here is a basic example of how to use the library to create a custom identity and sign a message.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { DelegationIdentity, Ed25519KeyIdentity, toDelegationIdentity, signCborMessage } from '@ldclabs/ic-auth';
|
|
43
|
+
|
|
44
|
+
async function main() {
|
|
45
|
+
// 1. Create a base identity (e.g., from a private key)
|
|
46
|
+
const baseIdentity = Ed25519KeyIdentity.generate();
|
|
47
|
+
|
|
48
|
+
// 2. Create an AuthIdentity
|
|
49
|
+
const authIdentity = toDelegationIdentity(baseIdentity);
|
|
50
|
+
|
|
51
|
+
// 4. Sign a message (e.g., a challenge from the backend)
|
|
52
|
+
const message = { challenge: 'Hello, world!' };
|
|
53
|
+
const signedEnvelope = await signCborMessage.signCborMessage(message);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
main();
|
|
57
|
+
```
|
|
9
58
|
|
|
10
59
|
## License
|
|
11
60
|
|
|
12
61
|
Copyright © 2024-2025 [LDC Labs](https://github.com/ldclabs).
|
|
13
62
|
|
|
14
|
-
Licensed under the MIT License. See [LICENSE](../../LICENSE-MIT) for details.
|
|
63
|
+
Licensed under the MIT License. See [LICENSE](../../LICENSE-MIT) for details.
|