@ascencia/id-core 0.1.0-rc.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/LICENSE +21 -0
- package/README.md +52 -0
- package/package.json +34 -0
- package/src/client.ts +657 -0
- package/src/discovery.ts +170 -0
- package/src/errors.ts +32 -0
- package/src/index.ts +29 -0
- package/src/pkce.ts +84 -0
- package/src/storage.ts +103 -0
- package/src/types.ts +253 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Karim
|
|
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/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @ascencia/id-core
|
|
2
|
+
|
|
3
|
+
Le client OAuth 2.1 / OIDC d'**Ascencia ID**. Navigateur et serveur, sans
|
|
4
|
+
dépendance runtime.
|
|
5
|
+
|
|
6
|
+
Il porte le flux `authorization_code` avec PKCE S256, l'échange et le
|
|
7
|
+
rafraîchissement des jetons, la découverte OIDC, et l'évaluation des
|
|
8
|
+
permissions côté client.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bun add @ascencia/id-core
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { createClient } from '@ascencia/id-core';
|
|
16
|
+
|
|
17
|
+
const client = createClient({
|
|
18
|
+
issuer: 'https://id.ascencia.re',
|
|
19
|
+
clientId: 'asc_cid_…',
|
|
20
|
+
redirectUri: 'https://mon-site.fr/callback',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Aller à l'écran de connexion
|
|
24
|
+
const { url } = await client.buildAuthorizeUrl();
|
|
25
|
+
location.assign(url);
|
|
26
|
+
|
|
27
|
+
// Au retour
|
|
28
|
+
const tokens = await client.handleCallback(location.search);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Ce qu'il ne fait pas
|
|
32
|
+
|
|
33
|
+
Il ne **vérifie** pas les jetons : vérifier une signature demande de récupérer
|
|
34
|
+
et de mettre en cache le JWKS, ce qui n'a de sens que côté serveur. C'est le
|
|
35
|
+
rôle de [`@ascencia/id-server`](https://www.npmjs.com/package/@ascencia/id-server).
|
|
36
|
+
|
|
37
|
+
Il ne stocke rien de sensible par défaut : le `code_verifier` d'une transaction
|
|
38
|
+
en cours vit dans `sessionStorage`, jamais le jeton de rafraîchissement. Pour un
|
|
39
|
+
site avec un serveur, préférer le montage confidentiel — les jetons restent
|
|
40
|
+
alors chez vous et le navigateur ne reçoit qu'un cookie.
|
|
41
|
+
|
|
42
|
+
## TypeScript
|
|
43
|
+
|
|
44
|
+
Le paquet est publié en **source TypeScript**. Les bundlers modernes le
|
|
45
|
+
transpilent sans rien faire ; avec Next.js, l'ajouter à `transpilePackages` :
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// next.config.ts
|
|
49
|
+
transpilePackages: ['@ascencia/id-core'],
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
MIT · [Documentation](https://id.ascencia.re/help)
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ascencia/id-core",
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
|
+
"description": "Client OIDC d'Ascencia ID – agnostique de tout framework, zéro dépendance runtime.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"scripts": {
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"build": "echo 'source-only package'"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@ascencia/id-rbac": "0.1.0-rc.1"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/pedrokarim/ascencia-auth.git",
|
|
29
|
+
"directory": "packages/core"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|