@aooth/idp 0.1.8
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 +40 -0
- package/dist/index.cjs +961 -0
- package/dist/index.d.cts +671 -0
- package/dist/index.d.mts +671 -0
- package/dist/index.mjs +943 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 aoothjs
|
|
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,40 @@
|
|
|
1
|
+
# @aooth/idp
|
|
2
|
+
|
|
3
|
+
Framework-agnostic OAuth2 / OIDC federated-login core for [aoothjs](https://github.com/moostjs/aoothjs).
|
|
4
|
+
|
|
5
|
+
This is the **phase 2** layer of the [External IdP RFC](../../IDP.md): the portable
|
|
6
|
+
pieces that have no framework dependency — provider clients, PKCE/state primitives,
|
|
7
|
+
ID-token verification, and the account-resolution algorithm. The moost wiring
|
|
8
|
+
(`OAuthController`, the provider-login workflow, DI binding) lives in `@aooth/auth-moost`
|
|
9
|
+
(phase 3).
|
|
10
|
+
|
|
11
|
+
## What's here
|
|
12
|
+
|
|
13
|
+
- **`IdentityProvider`** — the provider abstraction (`authorizationUrl` / `exchange`).
|
|
14
|
+
- **`OidcProvider`** — generic OpenID Connect: discovery, remote JWKS, and the full
|
|
15
|
+
OIDC Core 3.1.3.7 ID-token validation (pinned algs, `iss`/`aud`/`azp`, `exp`/`iat`/`nbf`
|
|
16
|
+
with clock skew, `nonce`, `at_hash`). Fails **closed** on JWKS/discovery errors.
|
|
17
|
+
- **`GoogleProvider`** — `OidcProvider` pinned to Google's issuer + `RS256`.
|
|
18
|
+
- **`FakeIdentityProvider`** — deterministic, network-free, for unit + e2e tests.
|
|
19
|
+
- **`OAuthProviderRegistry`** — holds the providers + `FederatedPolicy` + shared
|
|
20
|
+
signing/verification config; resolves `:provider`; builds the fixed `redirect_uri`.
|
|
21
|
+
- **PKCE / state** — `createPkcePair`, `generateNonce`, and `signState`/`verifyState`
|
|
22
|
+
(a compact HS256 JWT binding random + provider + redirect + optional verifier/nonce).
|
|
23
|
+
- **`FederatedLoginService`** — `resolveUser(profile)` (known → email-match → new) and
|
|
24
|
+
`linkIdentity` (interactive-link completion with the cross-user guard).
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add @aooth/idp @aooth/user @aooth/auth
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`@aooth/idp` depends on the concrete `UserService` (`@aooth/user`) and the shared
|
|
33
|
+
`Clock` (`@aooth/auth`), and uses [`jose`](https://github.com/panva/jose) for all
|
|
34
|
+
JWT/JWKS work.
|
|
35
|
+
|
|
36
|
+
## Security
|
|
37
|
+
|
|
38
|
+
Account matching by email is account-takeover sensitive — the default
|
|
39
|
+
`FederatedPolicy.emailMatch` is `require-interactive-link` (never silently merge).
|
|
40
|
+
See [IDP.md §4 / §7](../../IDP.md) for the full posture.
|