@monocloud/auth-core 0.0.0-canary-20251223204300
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 +122 -0
- package/dist/index.cjs +820 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +274 -0
- package/dist/index.d.mts +274 -0
- package/dist/index.mjs +815 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internal-DXHuqjJJ.mjs +343 -0
- package/dist/internal-DXHuqjJJ.mjs.map +1 -0
- package/dist/internal-DytuO03E.cjs +475 -0
- package/dist/internal-DytuO03E.cjs.map +1 -0
- package/dist/types-CnxqWHwA.d.cts +481 -0
- package/dist/types-DwJl9ZUf.d.mts +481 -0
- package/dist/utils/index.cjs +241 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +106 -0
- package/dist/utils/index.d.mts +106 -0
- package/dist/utils/index.mjs +230 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/internal.cjs +24 -0
- package/dist/utils/internal.d.cts +209 -0
- package/dist/utils/internal.d.mts +209 -0
- package/dist/utils/internal.mjs +3 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MonoCloud
|
|
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,122 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
**MonoCloud OIDC Client for JavaScript — a standards-compliant OpenID Connect client for secure authentication flows.**
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[MonoCloud](https://www.monocloud.com?utm_source=github&utm_medium=auth_js) is a modern, developer-friendly Identity & Access Management platform.
|
|
9
|
+
|
|
10
|
+
This package provides a **framework-agnostic OpenID Connect (OIDC) client** for interacting with MonoCloud. It supports industry-standard authentication flows including **Authorization Code Flow**, **PKCE**, **Pushed Authorization Requests (PAR)**, and token lifecycle management.
|
|
11
|
+
|
|
12
|
+
> This package focuses on **core OIDC primitives**. Framework-specific integrations (such as Next.js) are provided by higher-level packages built on top of `auth-core`.
|
|
13
|
+
|
|
14
|
+
## 📘 Documentation
|
|
15
|
+
|
|
16
|
+
- **Documentation:** [https://www.monocloud.com/docs](https://www.monocloud.com/docs?utm_source=github&utm_medium=auth_js)
|
|
17
|
+
|
|
18
|
+
## Supported Platforms
|
|
19
|
+
|
|
20
|
+
- **Node.js >= 16.0.0** (Requires `fetch` and Web Crypto API)
|
|
21
|
+
- **Modern Browsers**
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
- A **MonoCloud Tenant**
|
|
26
|
+
- A **Client** configured as a Web Application or SPA
|
|
27
|
+
|
|
28
|
+
## 📦 Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @monocloud/auth-core
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Initialization
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { MonoCloudOidcClient } from '@monocloud/auth-core';
|
|
38
|
+
|
|
39
|
+
const oidcClient = new MonoCloudOidcClient(
|
|
40
|
+
'https://<your-tenant-domain>',
|
|
41
|
+
'<your-client-id>',
|
|
42
|
+
{
|
|
43
|
+
// Optional: clientSecret for confidential clients
|
|
44
|
+
clientSecret: '<your-client-secret>',
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### Generate an Authorization URL
|
|
52
|
+
|
|
53
|
+
Initiate sign-in by generating an authorization URL.
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { generateNonce, generateState } from '@monocloud/auth-core/utils';
|
|
57
|
+
|
|
58
|
+
const authorizeUrl = await oidcClient.authorizationUrl({
|
|
59
|
+
redirectUri: '<registered callback url>',
|
|
60
|
+
scopes: 'openid profile email',
|
|
61
|
+
nonce: generateNonce(),
|
|
62
|
+
state: generateState(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Redirect the user to authorizeUrl
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
> Note: state and nonce should always be generated per request and validated on callback to prevent CSRF and token replay attacks.
|
|
69
|
+
|
|
70
|
+
### Handle Callback
|
|
71
|
+
|
|
72
|
+
After authentication, exchange the authorization code for tokens.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const session = await oidcClient.authenticate(
|
|
76
|
+
'<code>',
|
|
77
|
+
'<registered callback url>',
|
|
78
|
+
'openid profile email'
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
console.log(session.user); // User profile claims
|
|
82
|
+
console.log(session.idToken); // Raw ID Token
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Refresh a Session
|
|
86
|
+
|
|
87
|
+
Rotate tokens using the refresh token flow.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const refreshedSession = await oidcClient.refreshSession(session);
|
|
91
|
+
|
|
92
|
+
console.log(refreshedSession);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## When should I use `auth-core`?
|
|
96
|
+
|
|
97
|
+
Use **`@monocloud/auth-core`** if you need a **low-level, framework-agnostic** OpenID Connect client and want full control over the authentication flow.
|
|
98
|
+
|
|
99
|
+
This package is a good fit if you:
|
|
100
|
+
|
|
101
|
+
- Are building a **custom authentication integration**
|
|
102
|
+
- Need fine-grained control over **redirects, state, nonce, and PKCE**
|
|
103
|
+
- Are targeting **non-framework environments** (custom runtimes)
|
|
104
|
+
- Are building your own **framework adapter or SDK**
|
|
105
|
+
- Want a **pure OIDC client** without opinions about routing, cookies, or sessions
|
|
106
|
+
|
|
107
|
+
Higher-level packages are built on top of `auth-core` and provide framework-specific ergonomics while reusing the same underlying OIDC implementation.
|
|
108
|
+
|
|
109
|
+
## 🤝 Contributing & Support
|
|
110
|
+
|
|
111
|
+
### Issues & Feedback
|
|
112
|
+
|
|
113
|
+
- Use **GitHub Issues** for bug reports and feature requests.
|
|
114
|
+
- For tenant or account-specific help, contact MonoCloud Support through your dashboard.
|
|
115
|
+
|
|
116
|
+
### Security
|
|
117
|
+
|
|
118
|
+
Do **not** report security issues publicly. Please follow the contact instructions at: [https://www.monocloud.com/contact](https://www.monocloud.com/contact?utm_source=github&utm_medium=auth_js)
|
|
119
|
+
|
|
120
|
+
## 📄 License
|
|
121
|
+
|
|
122
|
+
Licensed under the **MIT License**. See the included [`LICENSE`](https://github.com/monocloud/auth-js/blob/main/LICENSE) file.
|