@fluxwp/core 0.4.5 → 0.4.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 +61 -2
- package/package.json +19 -4
package/README.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @fluxwp/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@fluxwp/core)
|
|
4
|
+
[](#license)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**A WordPress REST client and sign-in toolkit in TypeScript**, platform independent (browser, wp-admin,
|
|
7
|
+
Tauri desktop, React Native). The base of the [FluxWP](https://fluxwp.com) apps.
|
|
8
|
+
|
|
9
|
+
- **REST client** for `/wp-json/`: bearer tokens or application passwords, one retry after 401, extra
|
|
10
|
+
headers (nonce), same-origin checks for every path, upload progress, typed `ApiError`.
|
|
11
|
+
- **Sign-in:** OAuth 2 with PKCE, WordPress application passwords, one-time codes, API keys; site discovery.
|
|
12
|
+
- **Accounts:** several WordPress sites side by side, token storage, sessions.
|
|
13
|
+
- **i18n:** i18next setup with 10 languages and locale normalisation.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm i @fluxwp/core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { createClient, ApiError } from '@fluxwp/core';
|
|
25
|
+
|
|
26
|
+
const api = createClient({
|
|
27
|
+
siteUrl: 'https://example.com',
|
|
28
|
+
getCredentials: async () => ({ scheme: 'basic', token: btoa('admin:' + appPassword) }),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const posts = await api<{ id: number }[]>('wp/v2/posts', { query: { per_page: 5 } });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Inside wp-admin (cookie + nonce):
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const api = createClient({
|
|
38
|
+
siteUrl: location.origin,
|
|
39
|
+
getCredentials: async () => null,
|
|
40
|
+
credentials: 'same-origin',
|
|
41
|
+
extraHeaders: () => ({ 'X-WP-Nonce': wpApiSettings.nonce }),
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For GraphQL, pass this client to [`@fluxwp/graphql`](https://www.npmjs.com/package/@fluxwp/graphql).
|
|
46
|
+
|
|
47
|
+
## The FluxWP packages
|
|
48
|
+
|
|
49
|
+
| Package | What it is |
|
|
50
|
+
|---|---|
|
|
51
|
+
| [`@fluxwp/plugin-kit`](https://www.npmjs.com/package/@fluxwp/plugin-kit) | Build wp-admin React screens for your own WordPress plugin (Vite preset + `flx-kit` codegen) |
|
|
52
|
+
| [`@fluxwp/graphql`](https://www.npmjs.com/package/@fluxwp/graphql) | Typed GraphQL client and React hooks for Flux GraphQL (WPGraphQL) |
|
|
53
|
+
| [`@fluxwp/host`](https://www.npmjs.com/package/@fluxwp/host) | Host context of a screen: site client, user, locale |
|
|
54
|
+
| [`@fluxwp/ui`](https://www.npmjs.com/package/@fluxwp/ui) | React UI kit of FluxWP screens: Check, DatePicker, Modal, Icon … |
|
|
55
|
+
| [`@fluxwp/core`](https://www.npmjs.com/package/@fluxwp/core) | WordPress REST client, sign-in (OAuth PKCE, app passwords), accounts, i18n |
|
|
56
|
+
| [`@fluxwp/tokens`](https://www.npmjs.com/package/@fluxwp/tokens) | Design tokens: colours, spacing, radius, type, light / dark |
|
|
57
|
+
|
|
58
|
+
[FluxWP](https://fluxwp.com) is an open-source, all-in-one WordPress suite (donations, forms, e-commerce,
|
|
59
|
+
CRM, e-mail, AI, SEO) with a desktop and mobile app. Source:
|
|
60
|
+
[github.com/FluxWP/FluxWP](https://github.com/FluxWP/FluxWP). Questions and ideas: info@fluxwp.com.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
GPL-2.0-or-later
|
package/package.json
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluxwp/core",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.6",
|
|
4
|
+
"description": "WordPress REST API client and sign-in toolkit (OAuth PKCE, application passwords, multi-site accounts, i18n) for browser, desktop and React Native.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fluxwp",
|
|
7
|
+
"wordpress",
|
|
8
|
+
"typescript",
|
|
9
|
+
"wordpress-api",
|
|
10
|
+
"wp-json",
|
|
11
|
+
"rest-api",
|
|
12
|
+
"rest-client",
|
|
13
|
+
"oauth",
|
|
14
|
+
"pkce",
|
|
15
|
+
"application-passwords",
|
|
16
|
+
"i18n"
|
|
17
|
+
],
|
|
18
|
+
"author": "FluxWP <info@fluxwp.com> (https://fluxwp.com)",
|
|
5
19
|
"type": "module",
|
|
6
20
|
"license": "GPL-2.0-or-later",
|
|
7
|
-
"homepage": "https://
|
|
21
|
+
"homepage": "https://github.com/FluxWP/FluxWP/tree/main/packages/core#readme",
|
|
8
22
|
"repository": {
|
|
9
23
|
"type": "git",
|
|
10
24
|
"url": "git+https://github.com/FluxWP/FluxWP.git",
|
|
11
25
|
"directory": "packages/core"
|
|
12
26
|
},
|
|
13
27
|
"bugs": {
|
|
28
|
+
"url": "https://github.com/FluxWP/FluxWP/issues",
|
|
14
29
|
"email": "info@fluxwp.com"
|
|
15
30
|
},
|
|
16
31
|
"exports": {
|
|
@@ -30,7 +45,7 @@
|
|
|
30
45
|
],
|
|
31
46
|
"sideEffects": false,
|
|
32
47
|
"dependencies": {
|
|
33
|
-
"@fluxwp/tokens": "^0.4.
|
|
48
|
+
"@fluxwp/tokens": "^0.4.1",
|
|
34
49
|
"i18next": "^26.6.0",
|
|
35
50
|
"zustand": "^5.0.16"
|
|
36
51
|
},
|