@aurabase/aurabase-js 0.3.1 → 0.4.1
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 +26 -795
- package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.ts → dist/AuraClient-BcFE8u1v.d.cts} +1 -1
- package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.cts → dist/AuraClient-BcFE8u1v.d.ts} +1 -1
- package/{packages/aurabase/dist → dist}/index.d.cts +1 -1
- package/{packages/aurabase/dist → dist}/index.d.ts +1 -1
- package/{packages/aurabase/dist → dist}/ssr.d.cts +1 -1
- package/{packages/aurabase/dist → dist}/ssr.d.ts +1 -1
- package/package.json +74 -82
- package/.changeset/config.json +0 -11
- package/CHANGELOG.md +0 -30
- package/packages/ai/LICENSE +0 -21
- package/packages/ai/README.md +0 -106
- package/packages/ai/dist/index.cjs +0 -229
- package/packages/ai/dist/index.d.cts +0 -139
- package/packages/ai/dist/index.d.ts +0 -139
- package/packages/ai/dist/index.js +0 -226
- package/packages/ai/package.json +0 -61
- package/packages/aurabase/LICENSE +0 -21
- package/packages/aurabase/README.md +0 -64
- package/packages/aurabase/package.json +0 -80
- package/packages/aurabase/vitest.e2e.config.ts +0 -9
- package/packages/auth/LICENSE +0 -21
- package/packages/auth/README.md +0 -215
- package/packages/auth/dist/index.cjs +0 -1175
- package/packages/auth/dist/index.d.cts +0 -397
- package/packages/auth/dist/index.d.ts +0 -397
- package/packages/auth/dist/index.js +0 -1170
- package/packages/auth/package.json +0 -61
- package/packages/core/LICENSE +0 -21
- package/packages/core/README.md +0 -132
- package/packages/core/dist/index.cjs +0 -695
- package/packages/core/dist/index.d.cts +0 -1137
- package/packages/core/dist/index.d.ts +0 -1137
- package/packages/core/dist/index.js +0 -673
- package/packages/core/package.json +0 -57
- package/packages/db/LICENSE +0 -21
- package/packages/db/README.md +0 -152
- package/packages/db/VENDORED.md +0 -93
- package/packages/db/dist/index.cjs +0 -544
- package/packages/db/dist/index.d.cts +0 -1111
- package/packages/db/dist/index.d.ts +0 -1111
- package/packages/db/dist/index.js +0 -541
- package/packages/db/package.json +0 -62
- package/packages/functions/LICENSE +0 -21
- package/packages/functions/README.md +0 -96
- package/packages/functions/dist/index.cjs +0 -173
- package/packages/functions/dist/index.d.cts +0 -81
- package/packages/functions/dist/index.d.ts +0 -81
- package/packages/functions/dist/index.js +0 -168
- package/packages/functions/package.json +0 -60
- package/packages/gen/LICENSE +0 -21
- package/packages/gen/README.md +0 -84
- package/packages/gen/dist/cli.cjs +0 -334
- package/packages/gen/dist/cli.d.cts +0 -1
- package/packages/gen/dist/cli.d.ts +0 -1
- package/packages/gen/dist/cli.js +0 -332
- package/packages/gen/dist/index.cjs +0 -257
- package/packages/gen/dist/index.d.cts +0 -12
- package/packages/gen/dist/index.d.ts +0 -12
- package/packages/gen/dist/index.js +0 -255
- package/packages/gen/package.json +0 -66
- package/packages/notifications/LICENSE +0 -21
- package/packages/notifications/README.md +0 -134
- package/packages/notifications/dist/index.cjs +0 -128
- package/packages/notifications/dist/index.d.cts +0 -81
- package/packages/notifications/dist/index.d.ts +0 -81
- package/packages/notifications/dist/index.js +0 -125
- package/packages/notifications/package.json +0 -60
- package/packages/realtime/LICENSE +0 -21
- package/packages/realtime/README.md +0 -183
- package/packages/realtime/dist/index.cjs +0 -977
- package/packages/realtime/dist/index.d.cts +0 -259
- package/packages/realtime/dist/index.d.ts +0 -259
- package/packages/realtime/dist/index.js +0 -973
- package/packages/realtime/package.json +0 -60
- package/packages/storage/LICENSE +0 -21
- package/packages/storage/README.md +0 -141
- package/packages/storage/dist/index.cjs +0 -333
- package/packages/storage/dist/index.d.cts +0 -185
- package/packages/storage/dist/index.d.ts +0 -185
- package/packages/storage/dist/index.js +0 -329
- package/packages/storage/package.json +0 -60
- /package/{packages/aurabase/dist → dist}/index.cjs +0 -0
- /package/{packages/aurabase/dist → dist}/index.js +0 -0
- /package/{packages/aurabase/dist → dist}/ssr.cjs +0 -0
- /package/{packages/aurabase/dist → dist}/ssr.js +0 -0
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "aurabase",
|
|
3
|
-
"version": "0.3.0",
|
|
4
|
-
"description": "Official JavaScript/TypeScript client for Aurabase BaaS",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.cjs",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"default": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./dist/index.d.cts",
|
|
17
|
-
"default": "./dist/index.cjs"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"./ssr": {
|
|
21
|
-
"import": {
|
|
22
|
-
"types": "./dist/ssr.d.ts",
|
|
23
|
-
"default": "./dist/ssr.js"
|
|
24
|
-
},
|
|
25
|
-
"require": {
|
|
26
|
-
"types": "./dist/ssr.d.cts",
|
|
27
|
-
"default": "./dist/ssr.cjs"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"sideEffects": false,
|
|
32
|
-
"files": [
|
|
33
|
-
"dist",
|
|
34
|
-
"README.md",
|
|
35
|
-
"LICENSE"
|
|
36
|
-
],
|
|
37
|
-
"engines": {
|
|
38
|
-
"node": ">=20.0.0"
|
|
39
|
-
},
|
|
40
|
-
"license": "MIT",
|
|
41
|
-
"author": "Aurabase",
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "git+https://github.com/daylami555/aurabase.git",
|
|
45
|
-
"directory": "aurabase-js/packages/aurabase"
|
|
46
|
-
},
|
|
47
|
-
"homepage": "https://github.com/daylami555/aurabase/tree/main/aurabase-js/packages/aurabase#readme",
|
|
48
|
-
"bugs": {
|
|
49
|
-
"url": "https://github.com/daylami555/aurabase/issues"
|
|
50
|
-
},
|
|
51
|
-
"keywords": [
|
|
52
|
-
"aurabase",
|
|
53
|
-
"baas",
|
|
54
|
-
"backend-as-a-service",
|
|
55
|
-
"sdk",
|
|
56
|
-
"client"
|
|
57
|
-
],
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "tsup",
|
|
60
|
-
"test": "vitest run && tsc --noEmit -p tsconfig.test-d.json",
|
|
61
|
-
"test:types": "tsc --noEmit -p tsconfig.test-d.json",
|
|
62
|
-
"test:e2e": "RUN_E2E=true vitest run --config vitest.e2e.config.ts tests/integration.test.ts",
|
|
63
|
-
"typecheck": "tsc --noEmit"
|
|
64
|
-
},
|
|
65
|
-
"dependencies": {
|
|
66
|
-
"@aurabase/core": "workspace:*",
|
|
67
|
-
"@aurabase/auth": "workspace:*",
|
|
68
|
-
"@aurabase/db": "workspace:*",
|
|
69
|
-
"@aurabase/storage": "workspace:*",
|
|
70
|
-
"@aurabase/realtime": "workspace:*",
|
|
71
|
-
"@aurabase/functions": "workspace:*",
|
|
72
|
-
"@aurabase/ai": "workspace:*",
|
|
73
|
-
"@aurabase/notifications": "workspace:*"
|
|
74
|
-
},
|
|
75
|
-
"devDependencies": {
|
|
76
|
-
"tsup": "catalog:",
|
|
77
|
-
"typescript": "catalog:",
|
|
78
|
-
"vitest": "catalog:"
|
|
79
|
-
}
|
|
80
|
-
}
|
package/packages/auth/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Aurabase
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/packages/auth/README.md
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
# @aurabase/auth
|
|
2
|
-
|
|
3
|
-
Service d'authentification du SDK Aurabase : mots de passe, sessions, OAuth/PKCE, magic link, OTP, MFA et administration des utilisateurs.
|
|
4
|
-
|
|
5
|
-
 
|
|
6
|
-
|
|
7
|
-
> Pre-release — pas encore publié sur npm.
|
|
8
|
-
|
|
9
|
-
Fait partie du SDK **[aurabase](../aurabase)**. Installé automatiquement avec `aurabase` ; ce package est publié séparément pour un usage ciblé / tree-shaking.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm i @aurabase/auth
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
> Ce package dépend de `@aurabase/core` (`workspace:*` en interne, résolu en semver côté npm). Si vous utilisez déjà le package `aurabase`, `@aurabase/auth` est déjà inclus — cette installation ciblée n'est utile que pour composer votre propre client ou limiter la taille du bundle.
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
Dans l'usage courant, `AuthService` n'est jamais instancié directement : il est exposé par le client principal sous `aura.auth`.
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
import { createClient } from 'aurabase'
|
|
25
|
-
|
|
26
|
-
const aura = createClient('http://localhost:8080', 'my-project', 'aura_anon_xxx')
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Mot de passe
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
const signUp = await aura.auth.signUp({ email: 'user@example.com', password: 'correct horse battery staple' })
|
|
33
|
-
|
|
34
|
-
const signIn = await aura.auth.signInWithPassword({ email: 'user@example.com', password: 'correct horse battery staple' })
|
|
35
|
-
|
|
36
|
-
await aura.auth.signOut()
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Session
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
// getSession() n'est PAS un AuraResponse : il lit directement le store local (synchrone en pratique).
|
|
43
|
-
const { accessToken, user } = await aura.auth.getSession()
|
|
44
|
-
|
|
45
|
-
const refreshed = await aura.auth.refreshSession()
|
|
46
|
-
|
|
47
|
-
// Injecter une session existante (ex. tokens restaurés depuis un stockage sécurisé) : valide l'access token côté serveur.
|
|
48
|
-
await aura.auth.setSession('stored-access-token', 'stored-refresh-token')
|
|
49
|
-
|
|
50
|
-
const sessions = await aura.auth.listSessions()
|
|
51
|
-
await aura.auth.revokeSession(sessions.data![0].id)
|
|
52
|
-
await aura.auth.revokeAllSessions()
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### OAuth (implicite ou PKCE)
|
|
56
|
-
|
|
57
|
-
`signInWithOAuth` ne redirige plus « en dur » : il renvoie toujours `{ url }` (et redirige en plus via `window.location.href` si un `window` existe).
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
const { data, error } = await aura.auth.signInWithOAuth('github', {
|
|
61
|
-
redirectTo: 'http://localhost:3000/auth/callback',
|
|
62
|
-
scopes: 'read:user user:email',
|
|
63
|
-
flowType: 'pkce', // opt-in ; nécessite un store persistant (LocalAuthStore) côté navigateur
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
if (error) throw error
|
|
67
|
-
|
|
68
|
-
// Côté serveur / SSR : pas de redirection automatique, il faut rediriger manuellement vers data!.url
|
|
69
|
-
console.log(data!.url)
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Retour du provider (flux PKCE) :
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
const session = await aura.auth.exchangeCodeForSession('auth-code-from-callback')
|
|
76
|
-
|
|
77
|
-
// Mobile natif : échange d'un ID token provider (Google/Apple) contre une session Aurabase
|
|
78
|
-
await aura.auth.signInWithIdToken('google', 'id-token-from-provider')
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Magic link / OTP
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
await aura.auth.signInWithMagicLink({ email: 'user@example.com', redirect_url: 'http://localhost:3000/auth/callback' })
|
|
85
|
-
await aura.auth.verifyMagicLink('token-from-link')
|
|
86
|
-
|
|
87
|
-
await aura.auth.signInWithEmailOtp('user@example.com')
|
|
88
|
-
await aura.auth.verifyEmailOtp('user@example.com', '123456')
|
|
89
|
-
|
|
90
|
-
await aura.auth.signInWithSmsOtp('+15551234567')
|
|
91
|
-
await aura.auth.verifySmsOtp('+15551234567', '123456')
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Anonyme
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
await aura.auth.signInAnonymously()
|
|
98
|
-
|
|
99
|
-
// Convertit la session anonyme courante en compte email+password.
|
|
100
|
-
await aura.auth.promoteAnonymous({ email: 'user@example.com', password: 'correct horse battery staple' })
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Utilisateur, claims, mot de passe
|
|
104
|
-
|
|
105
|
-
```ts
|
|
106
|
-
const { data: user } = await aura.auth.getUser()
|
|
107
|
-
|
|
108
|
-
// Vérification locale JWKS (RS256/ES256) avec fallback getUser() (HS256 / JWKS vide).
|
|
109
|
-
const { data: claims } = await aura.auth.getClaims()
|
|
110
|
-
|
|
111
|
-
await aura.auth.updateUser({ data: { display_name: 'Ada' } })
|
|
112
|
-
|
|
113
|
-
// Révoque toutes les sessions et déconnecte le client après le changement.
|
|
114
|
-
await aura.auth.updatePassword('new-password', 'current-password')
|
|
115
|
-
|
|
116
|
-
await aura.auth.deleteUser('current-password')
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Réinitialisation de mot de passe
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
await aura.auth.resetPasswordForEmail({ email: 'user@example.com' })
|
|
123
|
-
await aura.auth.resetPassword('token-from-email', 'new-password')
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Le lien envoyé par email pointe vers `{site}/reset-password?token=<opaque>&project_id=<uuid>&type=recovery`.
|
|
127
|
-
Quand l'utilisateur ouvre ce lien, `detectSessionInUrl` (activé par défaut en navigateur) le
|
|
128
|
-
détecte au boot et émet l'événement `PASSWORD_RECOVERY` sur `onAuthStateChange`, en exposant le
|
|
129
|
-
token opaque via `recoveryToken` — **sans** ouvrir de session et **sans** émettre `SIGNED_IN`
|
|
130
|
-
(l'utilisateur n'est authentifié qu'après avoir choisi un nouveau mot de passe). L'app affiche
|
|
131
|
-
alors son formulaire « nouveau mot de passe » puis rappelle `resetPassword` :
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
aura.auth.onAuthStateChange(({ event, recoveryToken }) => {
|
|
135
|
-
if (event === 'PASSWORD_RECOVERY' && recoveryToken) {
|
|
136
|
-
// Affiche le formulaire, récupère le nouveau mot de passe, puis :
|
|
137
|
-
await aura.auth.resetPassword(recoveryToken, 'new-password')
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
Les paramètres (`token`, `project_id`, `type`) sont ensuite retirés de l'URL (best-effort,
|
|
143
|
-
via `history.replaceState`).
|
|
144
|
-
|
|
145
|
-
### Vérification d'email
|
|
146
|
-
|
|
147
|
-
```ts
|
|
148
|
-
await aura.auth.verifyEmail('token-from-email')
|
|
149
|
-
await aura.auth.resendVerificationEmail() // reprend l'email de la session courante si omis
|
|
150
|
-
await aura.auth.confirmEmailChange('token-from-email')
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### MFA (TOTP)
|
|
154
|
-
|
|
155
|
-
```ts
|
|
156
|
-
const enrollment = await aura.auth.mfaEnroll() // { otpauth_url, secret }
|
|
157
|
-
await aura.auth.mfaVerifySetup('123456')
|
|
158
|
-
|
|
159
|
-
await aura.auth.mfaVerify({ mfa_token: 'mfa-token-from-login-response', code: '123456' })
|
|
160
|
-
|
|
161
|
-
await aura.auth.regenerateRecoveryCodes('123456')
|
|
162
|
-
await aura.auth.mfaUnenroll('current-password')
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### Configuration publique
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
const settings = await aura.auth.getSettings()
|
|
169
|
-
const anonKey = await aura.auth.getAnonKey()
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### État d'authentification
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
const subscription = aura.auth.onAuthStateChange(({ event, user, accessToken }) => {
|
|
176
|
-
console.log(event, user?.email)
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
subscription.unsubscribe()
|
|
180
|
-
|
|
181
|
-
// Démonte le cycle de vie proactif (ticker de refresh, BroadcastChannel multi-onglets).
|
|
182
|
-
aura.dispose()
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Événements émis (valeur réelle de `AuthChangePayload.event`) : `INITIAL_SESSION`, `SIGNED_IN`, `SIGNED_OUT`, `TOKEN_REFRESHED`, `USER_UPDATED`, `MFA_CHALLENGE`, `PASSWORD_RECOVERY` (voir « Réinitialisation de mot de passe »).
|
|
186
|
-
|
|
187
|
-
### Administration (`AuthAdminService`)
|
|
188
|
-
|
|
189
|
-
Réservé au serveur (clé `service_role`). Deux façons d'y accéder :
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
// Via le client admin (recommandé)
|
|
193
|
-
import { createAdminClient } from 'aurabase'
|
|
194
|
-
|
|
195
|
-
const admin = createAdminClient('http://localhost:8080', 'my-project', process.env.SERVICE_ROLE_KEY!)
|
|
196
|
-
await admin.authAdmin.listUsers({ limit: 50 })
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
```ts
|
|
200
|
-
// Import direct du service (composition avancée)
|
|
201
|
-
import { AuthAdminService } from '@aurabase/auth'
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Méthodes clés : `listUsers`, `getUser`, `createUser`, `updateUser`, `deleteUser`, `banUser`, `unbanUser`, `generateLink`, `getUserStats`, `listUserIdentities`, `listSessions`, `revokeSession`, `getAuditLog`, `getSettings`, `updateSettings`, `listEmailTemplates`/`getEmailTemplate`/`updateEmailTemplate`/`deleteEmailTemplate`, `testEmailTemplate`.
|
|
205
|
-
|
|
206
|
-
## Limitations
|
|
207
|
-
|
|
208
|
-
- Pas de `resend()` / `reauthenticate()` / `verifyOtp()` unifiés (style Supabase) : chaque canal (magic link, email OTP, SMS OTP) a sa propre paire `signInWith*`/`verify*`.
|
|
209
|
-
- Pas de SSO/SAML.
|
|
210
|
-
- MFA limité au TOTP : pas de `listFactors()`, pas de niveau d'authentification (AAL), pas de MFA par téléphone.
|
|
211
|
-
- `getClaims()` en fallback (HS256 / JWKS vide) ne renvoie pas `exp`/`iat` — ne pas s'y fier après un fallback.
|
|
212
|
-
|
|
213
|
-
## Documentation
|
|
214
|
-
|
|
215
|
-
Référence complète du SDK (tous les services, types partagés, SSR) : [README racine](../../README.md).
|