Skip to content

Commit 502fe43

Browse files
committed
Update readme
1 parent 3cf929c commit 502fe43

3 files changed

Lines changed: 84 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
33
The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning].
44

55
## [Unreleased]
6+
### Changed
7+
- `core` - Update example usage in README.md
68

79
## [0.5.0] - 2025-09-23
810
### Changed

packages/core/README.md

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Unforgettable SDK
22

3-
`UnforgettableSdk` is a secure client-side toolkit used for key exchange and recovery within the [Unforgettable.app](https://unforgettable.app) ecosystem. It allows you to generate protected recovery links and retrieve encrypted secrets using a private RSA key pair.
3+
`Unforgettable SDK` is a secure client-side toolkit used for key exchange and recovery within the [Unforgettable.app](https://unforgettable.app) ecosystem. It allows you to generate secure links to Unforgettable.app and retrieve a private key recovered from the specified factors.
44

55
---
66

@@ -12,29 +12,88 @@ yarn add @rarimo/unforgettable-sdk
1212

1313
## Usage
1414

15-
### Quick Start
15+
### Create recovery key
16+
17+
1. Create a new SDK instance:
1618

1719
```ts
18-
import { UnforgettableSdk } from '@rarimo/unforgettable-sdk'
20+
import { UnforgettableSdk, RecoveryFactor } from '@rarimo/unforgettable-sdk'
21+
22+
const sdk = new UnforgettableSdk({
23+
// 'create' for creating a new key, 'restore' for recovering an existing one
24+
mode: 'create',
25+
// Optional, defaults to 'https://unforgettable.app'
26+
appUrl: 'https://custom.app',
27+
// Optional, defaults to 'https://api.unforgettable.app'
28+
apiUrl: 'https://api.custom.app',
29+
// Factors to use for recovery. If not provided, the user will select them during the recovery process.
30+
factors: [RecoveryFactor.Face, RecoveryFactor.Image, RecoveryFactor.Password]
31+
})
32+
```
1933

20-
// Initialize SDK in "create" or "restore" mode
21-
const sdk = new UnforgettableSdk({ mode: 'create' })
34+
2. Generate a secure recovery URL to share:
2235

23-
// Generate a secure recovery URL to share
36+
```ts
2437
const recoveryUrl = await sdk.getRecoveryUrl()
38+
// You can now share this URL or display it as a QR code.
39+
// This is a direct link to Unforgettable.app with embedded necessary query parameters.
2540
console.log('Recovery URL:', recoveryUrl)
41+
```
42+
43+
3. Get the recovered key and helper data URL:
2644

27-
// Later: recover the secret key
28-
const recoveredKey = await sdk.getRecoveredKey()
29-
console.log('Recovered Key:', recoveredKey)
45+
```ts
46+
try {
47+
const recoveryKey = await sdk.getRecoveredKey()
48+
// This is the recovered Unforgettable private key.
49+
// You can now create a wallet with it.
50+
console.log('Recovered key:', recoveryKey)
51+
} catch (error) {
52+
if (error?.httpStatus === 404) {
53+
// No recovery data found yet, try again later
54+
} else {
55+
console.error('Recovery error:', error)
56+
}
57+
}
3058
```
3159

32-
## Security Notes
60+
### Restore existing key
61+
62+
1. Create a new SDK instance with the wallet address:
3363

34-
- RSA keys are generated entirely on the client.
35-
- The private key never leaves the client environment.
36-
- Only the public key is sent in the URL (encoded in base64url).
37-
- Cryptographic operations use
64+
```ts
65+
import { UnforgettableSdk, RecoveryFactor } from '@rarimo/unforgettable-sdk'
66+
67+
const sdk = new UnforgettableSdk({
68+
mode: 'restore',
69+
walletAddress: '0x1234...abcd', // The wallet address associated with the key to recover
70+
appUrl: 'https://custom.app', // Optional
71+
apiUrl: 'https://api.custom.app', // Optional
72+
factors: [RecoveryFactor.Face, RecoveryFactor.Image, RecoveryFactor.Password] // Optional
73+
})
74+
```
75+
76+
2. Generate a secure recovery URL to share:
77+
78+
```ts
79+
const recoveryUrl = await sdk.getRecoveryUrl()
80+
console.log('Recovery URL:', recoveryUrl)
81+
```
82+
83+
3. Get the recovered key:
84+
85+
```ts
86+
try {
87+
const recoveryKey = await sdk.getRecoveredKey()
88+
console.log('Recovered key:', recoveryKey)
89+
} catch (error) {
90+
if (error?.httpStatus === 404) {
91+
// No recovery data found yet, try again later
92+
} else {
93+
console.error('Recovery error:', error)
94+
}
95+
}
96+
```
3897

3998
## License
4099

packages/react/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This package makes it easy to integrate identity verification into your React ap
77

88
- Simple QR code component for React
99
- Works with [Unforgettable SDK core library](https://github.com/rarimo/unforgettable-sdk/tree/main/packages/core)
10-
- Supports **create** and **restore** (basic & advanced verification modes)
10+
- Supports **create** and **restore** modes
1111
- Built-in polling with success/error callbacks
1212
- Fully customizable via props
1313

@@ -45,13 +45,17 @@ This component renders a QR code inside an `<a>` tag that links to the identity
4545
### Example usage
4646

4747
```tsx
48+
import UnforgettableQrCode from '@rarimo/unforgettable-sdk-react'
49+
50+
// ...
51+
4852
<UnforgettableQrCode
49-
mode={'create'}
50-
onSuccess={key => console.log('Recovered:', key)}
51-
onError={error => console.error(error)}
53+
mode='create'
5254
qrProps={{ size: 200 }}
53-
style={{ margin: '2rem auto', display: 'block' }}
5455
loader={<span>Loading...</span>}
56+
style={{ margin: '2rem auto', display: 'block' }}
57+
onSuccess={key => console.log('Recovered:', key)}
58+
onError={error => console.error(error)}
5559
/>
5660
```
5761

0 commit comments

Comments
 (0)