@doshi/sdk 0.0.0-stage → 0.2.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/LICENSE +9 -0
- package/README.md +41 -2
- package/dist/index.d.ts +65 -0
- package/dist/index.js +26069 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copyright (c) 2026 Doshi Ltd. All rights reserved.
|
|
2
|
+
|
|
3
|
+
@doshi/sdk is proprietary software. You may install and use it only under a written
|
|
4
|
+
agreement with Doshi Ltd, and only as that agreement allows. Without one, no licence is
|
|
5
|
+
granted to use, copy, modify or distribute it.
|
|
6
|
+
|
|
7
|
+
The third-party packages bundled into dist/index.js remain under their own licences. Their
|
|
8
|
+
notices are kept in that file, and the SBOM published with each release lists each package
|
|
9
|
+
with its licence.
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @doshi/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Doshi's Learn surface for your own page. Call `mount`, and the SDK renders into a shadow root
|
|
4
|
+
on the element you give it. It is one JavaScript file with its declarations, and it installs
|
|
5
|
+
no other package.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @doshi/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
How to sign a member in, mount the SDK and handle its events is
|
|
12
|
+
[developers.doshi.app/sdk](https://developers.doshi.app/sdk/).
|
|
13
|
+
|
|
14
|
+
## Versions
|
|
15
|
+
|
|
16
|
+
The SDK follows [semver](https://semver.org) over its public API: `mount`, its options and its
|
|
17
|
+
events. Prereleases are published under the `next` tag. What you are promised about versions,
|
|
18
|
+
cadence and support is
|
|
19
|
+
[developers.doshi.app/releases](https://developers.doshi.app/releases/).
|
|
20
|
+
|
|
21
|
+
## Verifying a release
|
|
22
|
+
|
|
23
|
+
Each release comes with its checksums, a CycloneDX SBOM and a Sigstore build attestation.
|
|
24
|
+
[developers.doshi.app/releases](https://developers.doshi.app/releases/#verify-a-release) serves
|
|
25
|
+
them, and gives the commands that check the tarball npm installs against them.
|
|
26
|
+
|
|
27
|
+
## Runtime dependencies
|
|
28
|
+
|
|
29
|
+
Every third-party package whose code reaches your page. All of them are bundled into
|
|
30
|
+
`dist/index.js`, and the package declares no dependencies, so installing it installs nothing
|
|
31
|
+
else.
|
|
32
|
+
|
|
33
|
+
| Package | Why |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| `react` | Renders the screens. Bundled rather than shared with the host, so the SDK always runs the React it was tested with. |
|
|
36
|
+
| `react-dom` | React's renderer for the browser, which draws into the SDK's shadow root. |
|
|
37
|
+
| `scheduler` | React DOM's work queue. React DOM does not run without it. |
|
|
38
|
+
| `@supabase/postgrest-js` | Reads the member's courses, lessons and progress from Doshi's data API. |
|
|
39
|
+
|
|
40
|
+
## Licence
|
|
41
|
+
|
|
42
|
+
Proprietary: see `LICENSE`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** Where Learn opens. A course or lesson the member cannot open falls back to the Learn home. */
|
|
2
|
+
export type StartTarget = {
|
|
3
|
+
view: "learning";
|
|
4
|
+
} | {
|
|
5
|
+
view: "course";
|
|
6
|
+
id: string;
|
|
7
|
+
} | {
|
|
8
|
+
view: "lesson";
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Base-URL overrides, for a host that proxies our traffic through its own origin. Each
|
|
13
|
+
* replaces the host the member's token would otherwise pick (`getToken`); images load from
|
|
14
|
+
* `data` too.
|
|
15
|
+
*/
|
|
16
|
+
export type HostUrls = {
|
|
17
|
+
/** Where the member's data and images are read from. */
|
|
18
|
+
data?: string;
|
|
19
|
+
/** Where lesson completions and rewards are written. */
|
|
20
|
+
api?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Why the member cannot use the SDK now. `unavailable`: what it needs could not be loaded.
|
|
24
|
+
* `auth_expired`: `getToken` stopped answering with a token we can use, told once, after
|
|
25
|
+
* which the SDK has cleared its content and asks the member to continue in the host's app.
|
|
26
|
+
* `during` is `load` when the member never saw a screen and `session` when they had.
|
|
27
|
+
*/
|
|
28
|
+
export type SdkError = {
|
|
29
|
+
code: "unavailable" | "auth_expired";
|
|
30
|
+
during: "load" | "session";
|
|
31
|
+
};
|
|
32
|
+
export type MountOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* The member's token, from the host's own backend. Asked for before the first render and
|
|
35
|
+
* again about 20 seconds before each token expires; a rejection means the member has no
|
|
36
|
+
* session. The SDK holds what it answers in memory only. The first token's issuer picks
|
|
37
|
+
* the environment, and a token from an issuer we do not know ends the session unless
|
|
38
|
+
* `urls` names both hosts.
|
|
39
|
+
*/
|
|
40
|
+
getToken: () => Promise<string>;
|
|
41
|
+
start?: StartTarget;
|
|
42
|
+
/** A BCP 47 tag such as `nl-NL`, used where the member's client speaks that language. */
|
|
43
|
+
locale?: string;
|
|
44
|
+
urls?: HostUrls;
|
|
45
|
+
/** Told once, when the first screen has rendered. */
|
|
46
|
+
onReady?: () => void;
|
|
47
|
+
/** Told once per code (`SdkError`). */
|
|
48
|
+
onError?: (error: SdkError) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Handed the URL of every outside link the member follows. Today's Learn screens have none.
|
|
51
|
+
* When set, the SDK never opens a link itself; unset, it opens one in a new window with
|
|
52
|
+
* `noopener`. It never navigates the host's page either way.
|
|
53
|
+
*/
|
|
54
|
+
onOpenLink?: (url: string) => void;
|
|
55
|
+
};
|
|
56
|
+
export type Mounted = {
|
|
57
|
+
/** The logout: removes everything the mount drew and forgets the member's token. */
|
|
58
|
+
unmount: () => void;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Draw Learn inside `element`, in a shadow root of its own. The tenant is the token's, so
|
|
62
|
+
* there is nothing to name here: a neutral loading state shows until the first token lands.
|
|
63
|
+
* One mount per page at a time; a second throws until the first is unmounted.
|
|
64
|
+
*/
|
|
65
|
+
export declare function mount(element: HTMLElement, options: MountOptions): Mounted;
|