@mythryl/app-sdk 0.1.5 → 0.1.6

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 CHANGED
@@ -25,27 +25,27 @@ on the server. Call it from effects and event handlers, which run in the browser
25
25
  | `sdk.ready()` | Signals that the app has loaded. The host removes its loading screen. |
26
26
  | `sdk.close()` | Closes the app. |
27
27
  | `sdk.getCapabilities()` | The capabilities the host supports. Check before calling optional features. |
28
- | `sdk.getContext()` | The signed-in person, how the app was launched, and the client environment. |
29
- | `sdk.auth.signin({ force? })` | `{ token }`: a JWT that authenticates the person to the app's own server. |
28
+ | `sdk.getContext()` | The signed-in user, how the app was launched, and the client environment. |
29
+ | `sdk.auth.signin({ force? })` | `{ token }`: a JWT that authenticates the user to the app's own server. |
30
30
  | `sdk.openProfile(actor)` | Opens a profile (handle or DID) in the host and minimises the app. |
31
31
  | `sdk.openPost(uri)` | Opens a post, by its `at://` URI, and minimises the app. |
32
32
  | `sdk.openTopic(slug)` | Opens a topic, by name without the slash, and minimises the app. |
33
- | `sdk.openUrl(url)` | Opens an `https` address in the browser once the person confirms. Rejects with `cancelled` if they decline. |
33
+ | `sdk.openUrl(url)` | Opens an `https` address in the browser once the user confirms. Rejects with `cancelled` if they decline. |
34
34
  | `sdk.openStorePage(domain?)` | Opens an app's store page in the host and minimises this app. Without a domain, it is this app's own page. |
35
35
  | `sdk.openApp({ domain, url? })` | Opens another mini app and closes this one. `url` is where to start, on that app's domain. |
36
- | `sdk.compose({ text?, embedUrl? })` | Opens the composer with a draft. `{ uri }` if the person posted, `{}` if they did not. |
37
- | `sdk.install()` | Asks the person to add this app to their library. Resolves at once if it is already there; rejects with `cancelled` if they decline. |
38
- | `sdk.follow(did)` | Asks the person to follow an account. Rejects with `cancelled` if they decline. |
36
+ | `sdk.compose({ text?, embedUrl? })` | Opens the composer with a draft. `{ uri }` if the user posted, `{}` if they did not. |
37
+ | `sdk.install()` | Asks the user to add this app to their library. Resolves at once if it is already there; rejects with `cancelled` if they decline. |
38
+ | `sdk.follow(did)` | Asks the user to follow an account. Rejects with `cancelled` if they decline. |
39
39
  | `sdk.on(event, listener)` | Subscribes to a host event. Returns a function that removes the listener. |
40
40
  | `sdk.dispose()` | Removes listeners and rejects pending calls with `cancelled`. |
41
41
 
42
42
  `openProfile`, `openPost`, `openTopic`, `openUrl` and `openApp` need the `navigation` capability. `compose`, `follow` and `install`
43
43
  each have a capability of the same name. Older hosts have none of them: check `sdk.getCapabilities()`
44
- first, or handle the `unsupported` rejection. Anything that writes (`compose`, `follow`, `install`) is confirmed by the person. A target the host cannot open rejects with `unavailable`.
44
+ first, or handle the `unsupported` rejection. Anything that writes (`compose`, `follow`, `install`) is confirmed by the user. A target the host cannot open rejects with `unavailable`.
45
45
 
46
46
  ### Events
47
47
 
48
- `minimised` and `maximised` are sent when the person hides the app and brings it back. `colorSchemeChanged` is sent with
48
+ `minimised` and `maximised` are sent when the user hides the app and brings it back. `colorSchemeChanged` is sent with
49
49
  `"light"` or `"dark"` when the host switches mode. `closing` and `resized` are defined by the protocol; hosts do not send
50
50
  them yet. `closing` is best effort and must not be relied on to save state.
51
51
 
@@ -78,7 +78,7 @@ const response = await fetch("/api/me", { headers });
78
78
  ### Errors
79
79
 
80
80
  A call that fails rejects with a `ProtocolError`. Its `code` is `cancelled`, `unsupported`, `not_consented`,
81
- `rate_limited` or `unavailable`. A call the host answers by itself that gets no answer within 30 seconds rejects with `unavailable`. A call that waits on the person (`openUrl`, `openApp`, `compose`, `follow`, `install`) has no time limit: it ends when they answer.
81
+ `rate_limited` or `unavailable`. A call the host answers by itself that gets no answer within 30 seconds rejects with `unavailable`. A call that waits on the user (`openUrl`, `openApp`, `compose`, `follow`, `install`) has no time limit: it ends when they answer.
82
82
 
83
83
  ## Outside a host
84
84
 
package/dist/channel.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface Channel {
8
8
  dispose: () => void;
9
9
  }
10
10
  /**
11
- * Correlates responses with requests by id, enforces the call timeout and dispatches events. A call that waits on a person
12
- * has no timeout (`WAITS_ON_PERSON`): it ends when they answer or the SDK is disposed.
11
+ * Correlates responses with requests by id, enforces the call timeout and dispatches events. A call that waits on a user
12
+ * has no timeout (`WAITS_ON_USER`): it ends when they answer or the SDK is disposed.
13
13
  */
14
14
  export declare const createChannel: (transport: Transport, timeoutMs?: number) => Channel;
package/dist/channel.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CALL_TIMEOUT_MS, MESSAGE_SOURCE, ProtocolError, isEventMessage, isResponseMessage, WAITS_ON_PERSON, } from "@mythryl/protocol";
1
+ import { CALL_TIMEOUT_MS, MESSAGE_SOURCE, ProtocolError, isEventMessage, isResponseMessage, WAITS_ON_USER, } from "@mythryl/protocol";
2
2
  /**
3
- * Correlates responses with requests by id, enforces the call timeout and dispatches events. A call that waits on a person
4
- * has no timeout (`WAITS_ON_PERSON`): it ends when they answer or the SDK is disposed.
3
+ * Correlates responses with requests by id, enforces the call timeout and dispatches events. A call that waits on a user
4
+ * has no timeout (`WAITS_ON_USER`): it ends when they answer or the SDK is disposed.
5
5
  */
6
6
  export const createChannel = (transport, timeoutMs = CALL_TIMEOUT_MS) => {
7
7
  const pending = new Map();
@@ -21,7 +21,7 @@ export const createChannel = (transport, timeoutMs = CALL_TIMEOUT_MS) => {
21
21
  clearTimeout(timer);
22
22
  pending.delete(id);
23
23
  };
24
- const timer = WAITS_ON_PERSON[method]
24
+ const timer = WAITS_ON_USER[method]
25
25
  ? undefined
26
26
  : setTimeout(() => {
27
27
  done();
package/dist/sdk.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface Sdk {
10
10
  getContext: () => Promise<AppContext>;
11
11
  auth: {
12
12
  /**
13
- * Returns a token that authenticates the person to the app's own server.
13
+ * Returns a token that authenticates the user to the app's own server.
14
14
  *
15
15
  * The token is a JWT signed by Mythryl. Its `aud` is the app's domain and it is valid for 10 minutes. Send it as a
16
16
  * bearer token and verify it on the server. The SDK caches the token and requests a new one when less than a
@@ -25,13 +25,13 @@ export interface Sdk {
25
25
  }>;
26
26
  };
27
27
  /** Subscribes to a host event. Returns a function that removes the listener. */
28
- /** Opens a person's profile in the host and minimises the app. `actor` is a handle or a DID. Check the `navigation` capability first. */
28
+ /** Opens a user's profile in the host and minimises the app. `actor` is a handle or a DID. Check the `navigation` capability first. */
29
29
  openProfile: (actor: string) => Promise<void>;
30
30
  /** Opens a post in the host and minimises the app. `uri` is the post's `at://` URI. */
31
31
  openPost: (uri: string) => Promise<void>;
32
32
  /** Opens a topic in the host and minimises the app. `slug` is the topic's name without the leading slash. */
33
33
  openTopic: (slug: string) => Promise<void>;
34
- /** Opens an `https` address in the browser after the person confirms. Rejects with `cancelled` if they decline. */
34
+ /** Opens an `https` address in the browser after the user confirms. Rejects with `cancelled` if they decline. */
35
35
  openUrl: (url: string) => Promise<void>;
36
36
  /** Opens an app's store page in the host and minimises the calling app. `domain` names the app; left out, it is this app's own page. */
37
37
  openStorePage: (domain?: string) => Promise<void>;
@@ -40,16 +40,16 @@ export interface Sdk {
40
40
  domain: string;
41
41
  url?: string;
42
42
  }) => Promise<void>;
43
- /** Opens the composer with a draft. Resolves with the post's URI if the person posted, and without one if they did not. Needs the `compose` capability. */
43
+ /** Opens the composer with a draft. Resolves with the post's URI if the user posted, and without one if they did not. Needs the `compose` capability. */
44
44
  compose: (options?: {
45
45
  text?: string;
46
46
  embedUrl?: string;
47
47
  }) => Promise<{
48
48
  uri?: string;
49
49
  }>;
50
- /** Asks the person to add this app to their library. Resolves at once if it is already there; rejects with `cancelled` if they decline. Needs the `install` capability. */
50
+ /** Asks the user to add this app to their library. Resolves at once if it is already there; rejects with `cancelled` if they decline. Needs the `install` capability. */
51
51
  install: () => Promise<void>;
52
- /** Asks the person to follow an account, by DID. Rejects with `cancelled` if they decline. Needs the `follow` capability. */
52
+ /** Asks the user to follow an account, by DID. Rejects with `cancelled` if they decline. Needs the `follow` capability. */
53
53
  follow: (did: string) => Promise<void>;
54
54
  on: <E extends EventName>(event: E, listener: (data: Events[E]) => void) => () => void;
55
55
  /** Removes listeners and rejects pending calls with `cancelled`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythryl/app-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "The browser SDK for Mythryl mini apps.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@mythryl/protocol": "0.1.5"
29
+ "@mythryl/protocol": "0.1.6"
30
30
  },
31
31
  "devDependencies": {
32
32
  "typescript": "~6.0.3",