@fenaura/sdk 0.2.1 → 0.2.2
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/bin/init.js +1 -1
- package/package.json +1 -2
- package/README.md +0 -124
package/bin/init.js
CHANGED
|
@@ -6,7 +6,7 @@ const path = require('path');
|
|
|
6
6
|
|
|
7
7
|
const argv = process.argv.slice(2);
|
|
8
8
|
const apiFlag = argv.find((a) => a.startsWith('--api='));
|
|
9
|
-
const API = apiFlag ? apiFlag.split('=')[1] : (process.env.FENAURA_API || '
|
|
9
|
+
const API = apiFlag ? apiFlag.split('=')[1] : (process.env.FENAURA_API || 'https://fenaura-runtime-production.up.railway.app');
|
|
10
10
|
const RULE_LINE = `/fenaura/* ${API}/:splat 200`;
|
|
11
11
|
const cwd = process.cwd();
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenaura/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Fenaura Client SDK — direct database access, auth, and storage from the browser",
|
|
5
5
|
"main": "js/fenaura-client.js",
|
|
6
6
|
"types": "js/fenaura-client.d.ts",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"js/fenaura-client.js",
|
|
9
9
|
"js/fenaura-client.d.ts",
|
|
10
10
|
"bin/init.js",
|
|
11
|
-
"README.md",
|
|
12
11
|
"LICENSE"
|
|
13
12
|
],
|
|
14
13
|
"bin": {
|
package/README.md
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
# @fenaura/sdk
|
|
2
|
-
|
|
3
|
-
Fenaura Client SDK — direct database access, auth, and storage from the browser. Zero dependencies. Works with any Fenaura BaaS backend.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @fenaura/sdk
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Requires Node >= 18 (browsers: modern evergreen with `fetch`).
|
|
12
|
-
|
|
13
|
-
## Quickstart
|
|
14
|
-
|
|
15
|
-
First set up the same-domain proxy once per frontend (recommended for cookie auth):
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npx @fenaura/auth-init
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Then in your app:
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import { createClient } from '@fenaura/sdk';
|
|
25
|
-
|
|
26
|
-
const fenaura = createClient('/fenaura', '<PROJECT_ID>');
|
|
27
|
-
|
|
28
|
-
await fenaura.auth.signIn({ email: 'jane@example.com', password: 'secret123' });
|
|
29
|
-
const { data, error } = await fenaura.from('todos').select('*').eq('done', false).limit(20);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Get your `<PROJECT_ID>` (project slug) from the Fenaura dashboard.
|
|
33
|
-
|
|
34
|
-
## Why the `/fenaura` proxy?
|
|
35
|
-
|
|
36
|
-
Fenaura auth uses `HttpOnly SameSite=Strict` session cookies. Calling the API cross-origin would drop cookies and hit CORS issues. The proxy maps same-origin `/fenaura/*` to your API, so auth just works in dev and prod with no code changes.
|
|
37
|
-
|
|
38
|
-
Direct (non-proxy) mode is for backends / Node scripts:
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
const fenaura = createClient('https://api.yours.com', '<PROJECT_ID>');
|
|
42
|
-
fenaura.setSession(token); // raw token from signIn(..., { browser: false })
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Database
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
// select
|
|
49
|
-
await fenaura.from('users').select('id,name').eq('role', 'admin').order('created_at').limit(10);
|
|
50
|
-
// insert
|
|
51
|
-
await fenaura.from('users').insert({ name: 'John' });
|
|
52
|
-
// update + delete are chained then awaited (Supabase-style)
|
|
53
|
-
await fenaura.from('users').update({ name: 'Jane' }).eq('id', 1).execute();
|
|
54
|
-
await fenaura.from('users').delete().eq('id', 1).execute();
|
|
55
|
-
// upsert takes a single object only
|
|
56
|
-
await fenaura.from('users').upsert({ id: 1, name: 'Jane' });
|
|
57
|
-
// single row
|
|
58
|
-
const user = await fenaura.from('users').select('*').eq('id', 1).single();
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Filters: `eq, neq, gt, gte, lt, lte, like, ilike, in, is, contains, containedBy, overlaps, textSearch, not, or`. Table/column names are validated client-side.
|
|
62
|
-
|
|
63
|
-
## Auth
|
|
64
|
-
|
|
65
|
-
```js
|
|
66
|
-
await fenaura.auth.signUp({ email, password });
|
|
67
|
-
await fenaura.auth.signIn({ email, password });
|
|
68
|
-
await fenaura.auth.signOut();
|
|
69
|
-
await fenaura.auth.getUser(); // current user via cookie or Bearer
|
|
70
|
-
await fenaura.auth.getSession();
|
|
71
|
-
|
|
72
|
-
// OAuth (12 providers: google, github, microsoft, apple, ...)
|
|
73
|
-
const { data } = await fenaura.auth.signInWithOAuth('google', { redirectTo: 'https://app.yours.com/auth/callback' });
|
|
74
|
-
// non-web / backend: { browser: false } returns { data: { url } }, then:
|
|
75
|
-
await fenaura.auth.exchangeCodeForSession(code);
|
|
76
|
-
|
|
77
|
-
// email verification / password reset / magic link
|
|
78
|
-
await fenaura.auth.sendVerificationCode({ email });
|
|
79
|
-
await fenaura.auth.submitVerificationCode({ email, code });
|
|
80
|
-
await fenaura.auth.sendPasswordReset({ email });
|
|
81
|
-
await fenaura.auth.confirmPasswordReset({ email, code, newPassword });
|
|
82
|
-
await fenaura.auth.sendMagicLink({ email });
|
|
83
|
-
await fenaura.auth.verifyMagicCode({ email, code });
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Pass `{ browser: false }` to `signUp/signIn/submitVerificationCode/confirmPasswordReset/verifyMagicCode` in non-browser contexts to get the raw token in `data.token` instead of a cookie.
|
|
87
|
-
|
|
88
|
-
## Storage
|
|
89
|
-
|
|
90
|
-
Chunked (1 MiB), resumable per-chunk retry, with progress:
|
|
91
|
-
|
|
92
|
-
```js
|
|
93
|
-
const { data, error } = await fenaura.storage.from('avatars').upload('user1.jpg', file, {
|
|
94
|
-
compress: true, // on-device image resize / gzip before upload
|
|
95
|
-
onProgress: ({ sentBytes, totalBytes }) => console.log(sentBytes / totalBytes),
|
|
96
|
-
});
|
|
97
|
-
const dl = await fenaura.storage.from('avatars').download('user1.jpg');
|
|
98
|
-
const url = fenaura.storage.from('avatars').getPublicUrl('user1.jpg'); // session-gated, needs cookie
|
|
99
|
-
const signed = await fenaura.storage.from('avatars').createSignedUrl('user1.jpg', 3600); // public HMAC link
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
`compressFile(file, opts)` is also exported standalone. Images use canvas, other files use `CompressionStream`.
|
|
103
|
-
|
|
104
|
-
## TypeScript
|
|
105
|
-
|
|
106
|
-
Types ship built-in:
|
|
107
|
-
|
|
108
|
-
```ts
|
|
109
|
-
import { createClient, type FenauraClient } from '@fenaura/sdk';
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Bins
|
|
113
|
-
|
|
114
|
-
This package also ships the proxy installer:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
npx -p @fenaura/sdk fenaura-init
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Prefer the standalone `npx @fenaura/auth-init`.
|
|
121
|
-
|
|
122
|
-
## License
|
|
123
|
-
|
|
124
|
-
MIT — see LICENSE.
|