@oasisprotocol/privana-sdk 0.5.2 → 0.5.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 +34 -0
- package/dist/{chunk-UHXVYWTF.cjs → chunk-7KEQHWZB.cjs} +902 -240
- package/dist/chunk-7KEQHWZB.cjs.map +1 -0
- package/dist/{chunk-ZVUMV4NR.js → chunk-DZURIIRE.js} +898 -242
- package/dist/chunk-DZURIIRE.js.map +1 -0
- package/dist/index.cjs +1356 -336
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +24 -11
- package/dist/index.d.ts +24 -11
- package/dist/index.js +1116 -104
- package/dist/index.js.map +1 -1
- package/dist/on-ramp.cjs +3 -3
- package/dist/on-ramp.d.cts +5 -4
- package/dist/on-ramp.d.ts +5 -4
- package/dist/on-ramp.js +1 -1
- package/dist/{pending-lock-BdkuMjmY.d.cts → pending-lock-f4bWWTyN.d.cts} +41 -7
- package/dist/{pending-lock-BdkuMjmY.d.ts → pending-lock-f4bWWTyN.d.ts} +41 -7
- package/package.json +1 -1
- package/dist/chunk-UHXVYWTF.cjs.map +0 -1
- package/dist/chunk-ZVUMV4NR.js.map +0 -1
package/README.md
CHANGED
|
@@ -117,6 +117,40 @@ The hooks cache the returned `X-SIWE-Token`, dedupe concurrent auth so a group o
|
|
|
117
117
|
private-read hooks only triggers one sign prompt, and retry once on `401` by re-authenticating
|
|
118
118
|
through the same shared in-flight auth request.
|
|
119
119
|
|
|
120
|
+
### Direct in-app SIWE auth (`siweAuth`)
|
|
121
|
+
|
|
122
|
+
For same-origin apps that want an explicit authenticated session (and JWT-authenticated writes),
|
|
123
|
+
enable `siweAuth` on `PrivanaProvider`. The connected wallet signs an EIP-4361 message in-app and
|
|
124
|
+
`useSiweAuth()` exposes `login`, `logout`, `session`, and the raw `tokens`:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { PrivanaProvider, useSiweAuth } from '@oasisprotocol/privana-sdk'
|
|
128
|
+
;<PrivanaProvider siweAuth={{ autoLogin: true }}>
|
|
129
|
+
<AuthGate />
|
|
130
|
+
</PrivanaProvider>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`siweAuth` accepts `true`, or an object with `autoLogin` (default `true`) and `persistJwt`
|
|
134
|
+
(default `false`). It is mutually exclusive with `hostedAuth`.
|
|
135
|
+
|
|
136
|
+
#### Persistent JWT sessions (`persistJwt`)
|
|
137
|
+
|
|
138
|
+
Set `persistJwt: true` to mirror the session in `localStorage` (key scoped by API URL and chain ID)
|
|
139
|
+
so a page reload restores an active session without another signature prompt:
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
;<PrivanaProvider siweAuth={{ autoLogin: true, persistJwt: true }}>
|
|
143
|
+
<App />
|
|
144
|
+
</PrivanaProvider>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Logout captures the refresh token, clears local and cross-tab state immediately, suppresses
|
|
148
|
+
automatic re-login, and attempts server-side revocation.
|
|
149
|
+
|
|
150
|
+
> **Security note:** storing long-lived refresh credentials in `localStorage` makes them reachable
|
|
151
|
+
> from any JavaScript running on the page. An XSS vulnerability could exfiltrate them and forge a
|
|
152
|
+
> session, so only enable `persistJwt` on origins you fully control.
|
|
153
|
+
|
|
120
154
|
### Hosted redirect auth for cross-domain apps
|
|
121
155
|
|
|
122
156
|
For widget or cross-domain frontends, configure `hostedAuth` on `PrivanaProvider` and use
|