@synonymdev/pubky 0.7.0 → 0.8.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@synonymdev/pubky",
3
3
  "type": "module",
4
4
  "description": "Pubky client",
5
- "version": "0.7.0",
5
+ "version": "0.8.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/pubky.d.ts CHANGED
@@ -196,6 +196,22 @@ export class AuthFlow {
196
196
  * - `RequestError` if relay/network fails
197
197
  */
198
198
  awaitToken(): Promise<AuthToken>;
199
+ /**
200
+ * Resume a previously started auth flow from its saved `authorizationUrl` (standalone).
201
+ * Prefer `pubky.resumeAuthFlow()` to reuse a facade client; this creates a default (mainnet) client.
202
+ *
203
+ * Relay messages expire after ~5 minutes; resume is only viable in that window.
204
+ * See `Pubky.resumeAuthFlow()` / `Pubky.startAuthFlow()` for full guidance.
205
+ *
206
+ * **Security:** `authorizationUrl` contains the `client_secret`.
207
+ * Delete it from storage as soon as resume completes or is abandoned.
208
+ *
209
+ * @param {string} authorizationUrl The `pubkyauth://…` URL from a previous flow.
210
+ * @returns {AuthFlow} A flow reconnected to the original relay channel.
211
+ * @throws {PubkyError}
212
+ * - `{ name: "AuthenticationError" }` if the URL is invalid or not a signin/signup link
213
+ */
214
+ static resume(authorization_url: string): AuthFlow;
199
215
  /**
200
216
  * Start a flow (standalone).
201
217
  * Prefer `pubky.startAuthFlow()` to reuse a facade client.
@@ -239,10 +255,14 @@ export class AuthFlow {
239
255
  /**
240
256
  * Return the authorization deep link (URL) to show as QR or open on the signer device.
241
257
  *
258
+ * **Security:** This URL contains the `client_secret` in plaintext.
259
+ * Treat it as a short-lived secret and delete it after the flow completes.
260
+ * See `Pubky.startAuthFlow()` docs for storage guidance.
261
+ *
242
262
  * @returns {string} A `pubkyauth://…` or `https://…` URL with channel info.
243
263
  *
244
264
  * @example
245
- * renderQr(flow.authorizationUrl());
265
+ * renderQr(flow.authorizationUrl);
246
266
  */
247
267
  readonly authorizationUrl: string;
248
268
  }
@@ -809,6 +829,23 @@ export class Pubky {
809
829
  * const restored = await pubky.restoreSession(localStorage.getItem("pubky-session")!);
810
830
  */
811
831
  restoreSession(exported: string): Promise<Session>;
832
+ /**
833
+ * Resume a previously started **pubkyauth** flow from its saved `authorizationUrl`.
834
+ *
835
+ * The relay inbox retains messages for **~5 minutes**. Resume is only
836
+ * viable within that window; afterwards start a fresh flow.
837
+ *
838
+ * **Security:** The URL contains the `client_secret` in plaintext.
839
+ * Delete it from storage as soon as the resumed flow completes.
840
+ * See `startAuthFlow()` docs for full storage guidance.
841
+ *
842
+ * @param {string} authorizationUrl The `pubkyauth://…` URL from a previous flow.
843
+ * @returns {AuthFlow} A flow reconnected to the original relay channel.
844
+ * @throws {PubkyError}
845
+ * - `{ name: "AuthenticationError" }` if the URL is invalid or not a signin/signup link
846
+ * - `{ name: "RequestError" }` on network/relay failure
847
+ */
848
+ resumeAuthFlow(authorization_url: string): AuthFlow;
812
849
  /**
813
850
  * Create a `Signer` from an existing `Keypair`.
814
851
  *
@@ -830,6 +867,10 @@ export class Pubky {
830
867
  * - `actions` is any combo of `r` and/or `w` (order normalized; `wr` -> `rw`).
831
868
  * Pass `""` for no scopes (read-only public session).
832
869
  *
870
+ * **Security:** `authorizationUrl` contains the `client_secret` in plaintext.
871
+ * If you need resume after refresh/app switch, save it in `sessionStorage`
872
+ * (not `localStorage`), then delete it once approval arrives or is abandoned.
873
+ *
833
874
  * @param {string} capabilities Comma-separated caps, e.g. `"/pub/app/:rw,/pub/foo/file:r"`.
834
875
  * @param {AuthFlowKind} kind The kind of authentication flow to perform.
835
876
  * Examples:
package/pubky_bg.wasm CHANGED
Binary file