ns-auth-sdk 1.2.6 → 1.3.0
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 +33 -16
- package/dist/index.cjs +1397 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +115 -16
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +289 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +232 -157
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1342 -1206
- package/dist/index.mjs.map +1 -1
- package/dist/utils-BR2TqhEA.cjs +3 -0
- package/dist/utils-BVvtCpMQ.mjs +3 -0
- package/dist/utils-CV_lg5Ir.mjs +492 -0
- package/dist/utils-CV_lg5Ir.mjs.map +1 -0
- package/dist/utils-CxLeFzNn.cjs +528 -0
- package/dist/utils-CxLeFzNn.cjs.map +1 -0
- package/package.json +18 -17
- package/dist/index.d.ts +0 -214
- package/dist/index.js +0 -1234
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
# NS Auth SDK
|
|
2
|
+
|
|
3
|
+
_The simplest way of doing Auth with seamless and decentralized Key-Management for SSO, Authentication, Membership, and Profile-Management_
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
### Who is it for?
|
|
6
|
+
Being trusted by Financial Institutions for Client Onboarding and Digital Communities for Membership Management. Examples include [NSAuth](https://nsauth.vercel.app/) and [OneBoard](https://www.oneboard.li/).
|
|
7
|
+
The SDK enables client-side managing of private-keys with WebAuthn passkeys (FIDO2 credentials). By leveraging passkeys, users avoid traditional private‑key backups and password hassles, relying instead on biometric or device‑based authentication. The keys are compatible with common blockchains like Bitcoin and Ethereum and data is stored as events on public relays and can be encrypted.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
## The Open Alternative for Auth
|
|
10
|
+
Open‑source, client‑side, decentralized single‑sign‑on (SSO) like NSAuth is superior because it puts the user’s identity and cryptographic keys directly in the hands of the individual, eliminating reliance on any central authority that could become a single point of failure, a privacy sinkhole, or a bottleneck for policy updates. By storing a self‑sovereign credential on the device’s secure enclave and validating access against a signed, versioned member list, every interaction—from unlocking a gym door to logging into an online course is verified instantly without ever transmitting personal identifiers. This architecture enables real‑time privilege changes (a badge upgrade or a revocation propagates the moment the list is updated), removes passwords and phishing risk through biometric or hardware‑key authentication, and works uniformly for anyone, including stateless persons or diaspora communities, because trust is derived from cryptographic proofs rather than government‑issued IDs. Moreover, being open source lets developers audit the code, contribute improvements, and ensure transparency, while the decentralized design guarantees that no single entity can unilaterally alter membership rules, providing stronger governance, auditability, and privacy than traditional, server‑centric SSO solutions.
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
PRF Direct Method – Derive the private key directly from the PRF value produced by a passkey. Encryption Method – Encrypt an existing private key with a key derived from the passkey’s PRF output. WebAuthn PRF Extension The PRF (Pseudo‑Random Function) extension, part of WebAuthn Level 3, yields deterministic 32‑byte high‑entropy values from an authenticator’s internal private key and a supplied salt. The same credential ID and salt always generate the same PRF output, which never leaves the device except during authentication.
|
|
12
|
+
## Technology
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
### Choose your Backend
|
|
15
|
+
NSAuth is designed as a frontend SSO where data can be synced in a trust minimized way. The basics are there for extensions to interoperate with Farcaster, Nostr, Ethereum, Solana or even regular webservers.
|
|
16
|
+
|
|
17
|
+
### Two Approaches
|
|
18
|
+
#### PRF Direct Method
|
|
19
|
+
Derive the private key directly from the PRF value produced by a passkey.
|
|
20
|
+
|
|
21
|
+
#### Encryption Method
|
|
22
|
+
Encrypt an existing private key with a key derived from the passkey’s PRF output. WebAuthn PRF Extension The PRF (Pseudo‑Random Function) extension, part of WebAuthn Level 3, yields deterministic 32‑byte high‑entropy values from an authenticator’s internal private key and a supplied salt. The same credential ID and salt always generate the same PRF output, which never leaves the device except during authentication.
|
|
23
|
+
|
|
24
|
+
### Using PRF Values as Private Keys
|
|
11
25
|
A 32‑byte PRF output can serve as a private key if it falls within the secp256k1 range (1 ≤ value < n). The chance of falling outside this range is astronomically low (~2⁻²²⁴), so explicit range checks are generally unnecessary.
|
|
12
26
|
|
|
13
|
-
Restoration Steps
|
|
27
|
+
### Restoration Steps
|
|
14
28
|
Install the client on a new device. Fetch the latest kind 30100 event for the target public key. Extract the PWKBlob and decrypt it with the passkey’s PRF value. Use the recovered private key for signing. Multiple passkeys can each have their own PWKBlob, allowing redundancy across devices.
|
|
15
29
|
|
|
16
30
|
|
|
@@ -41,13 +55,13 @@ const authService = new AuthService({
|
|
|
41
55
|
storageKey: 'nsauth_keyinfo',
|
|
42
56
|
});
|
|
43
57
|
|
|
44
|
-
// Initialize relay service with
|
|
58
|
+
// Initialize relay service with EventStore
|
|
45
59
|
const relayService = new RelayService({
|
|
46
|
-
relayUrls: ['wss://relay.
|
|
60
|
+
relayUrls: ['wss://relay.io'],
|
|
47
61
|
});
|
|
48
62
|
|
|
49
|
-
// Initialize with
|
|
50
|
-
const eventStore = new EventStore(/*
|
|
63
|
+
// Initialize with EventStore
|
|
64
|
+
const eventStore = new EventStore(/* config */);
|
|
51
65
|
relayService.initialize(eventStore);
|
|
52
66
|
```
|
|
53
67
|
|
|
@@ -156,10 +170,6 @@ function MembershipPageComponent() {
|
|
|
156
170
|
|
|
157
171
|
## API Reference
|
|
158
172
|
|
|
159
|
-
### AuthService
|
|
160
|
-
|
|
161
|
-
Wrapper around `nosskey-sdk` for WebAuthn/Passkey integration.
|
|
162
|
-
|
|
163
173
|
#### Methods
|
|
164
174
|
|
|
165
175
|
- `createPasskey(username?: string): Promise<Uint8Array>` - Create a new passkey
|
|
@@ -178,7 +188,8 @@ Service for communicating with Nostr relays using applesauce-core.
|
|
|
178
188
|
|
|
179
189
|
#### Methods
|
|
180
190
|
|
|
181
|
-
- `initialize(eventStore: EventStore): void` - Initialize with
|
|
191
|
+
- `initialize(eventStore: EventStore): void` - Initialize with EventStore
|
|
192
|
+
- `getRelays(): string[]` - Get current relay URLs
|
|
182
193
|
- `setRelays(urls: string[]): void` - Set relay URLs
|
|
183
194
|
- `publishEvent(event: NostrEvent, timeoutMs?: number): Promise<boolean>` - Publish event
|
|
184
195
|
- `fetchProfile(pubkey: string): Promise<ProfileMetadata | null>` - Fetch profile
|
|
@@ -209,10 +220,16 @@ import { EventStore } from 'applesauce-core';
|
|
|
209
220
|
import { RelayService } from 'ns-auth-sdk';
|
|
210
221
|
|
|
211
222
|
const eventStore = new EventStore({
|
|
212
|
-
//
|
|
223
|
+
// configuration
|
|
213
224
|
});
|
|
214
225
|
|
|
215
226
|
const relayService = new RelayService();
|
|
216
227
|
relayService.initialize(eventStore);
|
|
217
228
|
```
|
|
218
229
|
|
|
230
|
+
## Security Guidance
|
|
231
|
+
|
|
232
|
+
- Configure a strict Content Security Policy (CSP) in the host app to restrict script and image sources.
|
|
233
|
+
- Add rate limiting or debouncing around profile queries and event publishing in the host app or API layer.
|
|
234
|
+
- Avoid surfacing raw error details to end users; log detailed errors in secure logs.
|
|
235
|
+
|