@edirect/oidc-client 11.0.65 → 11.0.66
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/package.json +9 -31
- package/dist/README.md +0 -136
- package/dist/package.json +0 -23
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
- /package/{dist/src → src}/connect.d.ts +0 -0
- /package/{dist/src → src}/connect.d.ts.map +0 -0
- /package/{dist/src → src}/connect.js +0 -0
- /package/{dist/src → src}/grant-type/client_credentials.d.ts +0 -0
- /package/{dist/src → src}/grant-type/client_credentials.d.ts.map +0 -0
- /package/{dist/src → src}/grant-type/client_credentials.js +0 -0
- /package/{dist/src → src}/grant-type/password.d.ts +0 -0
- /package/{dist/src → src}/grant-type/password.d.ts.map +0 -0
- /package/{dist/src → src}/grant-type/password.js +0 -0
- /package/{dist/src → src}/grant-type/sso.d.ts +0 -0
- /package/{dist/src → src}/grant-type/sso.d.ts.map +0 -0
- /package/{dist/src → src}/grant-type/sso.js +0 -0
- /package/{dist/src → src}/index.d.ts +0 -0
- /package/{dist/src → src}/index.d.ts.map +0 -0
- /package/{dist/src → src}/index.js +0 -0
- /package/{dist/src → src}/token.d.ts +0 -0
- /package/{dist/src → src}/token.d.ts.map +0 -0
- /package/{dist/src → src}/token.js +0 -0
- /package/{dist/src → src}/types/connect.type.d.ts +0 -0
- /package/{dist/src → src}/types/connect.type.d.ts.map +0 -0
- /package/{dist/src → src}/types/connect.type.js +0 -0
- /package/{dist/src → src}/types/error-handler.type.d.ts +0 -0
- /package/{dist/src → src}/types/error-handler.type.d.ts.map +0 -0
- /package/{dist/src → src}/types/error-handler.type.js +0 -0
- /package/{dist/src → src}/types/token-set.type.d.ts +0 -0
- /package/{dist/src → src}/types/token-set.type.d.ts.map +0 -0
- /package/{dist/src → src}/types/token-set.type.js +0 -0
- /package/{dist/src → src}/utils/error-handler.d.ts +0 -0
- /package/{dist/src → src}/utils/error-handler.d.ts.map +0 -0
- /package/{dist/src → src}/utils/error-handler.js +0 -0
- /package/{dist/src → src}/utils/parse-token.d.ts +0 -0
- /package/{dist/src → src}/utils/parse-token.d.ts.map +0 -0
- /package/{dist/src → src}/utils/parse-token.js +0 -0
package/package.json
CHANGED
|
@@ -1,45 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edirect/oidc-client",
|
|
3
|
-
"version": "11.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"module": "./dist/esm/index.js",
|
|
7
|
-
"types": "./dist/types/index.d.ts",
|
|
3
|
+
"version": "11.0.66",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
8
6
|
"exports": {
|
|
9
7
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
8
|
+
"import": "./src/index.js",
|
|
9
|
+
"default": "./src/index.js",
|
|
10
|
+
"require": "./src/index.js",
|
|
11
|
+
"types": "./src/index.d.ts"
|
|
13
12
|
},
|
|
14
13
|
"./package.json": "./package.json"
|
|
15
14
|
},
|
|
16
15
|
"files": [
|
|
17
|
-
"
|
|
16
|
+
"src"
|
|
18
17
|
],
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"openid-client": "^6.8.6",
|
|
21
20
|
"tslib": "^2.8.1"
|
|
22
21
|
},
|
|
23
|
-
"
|
|
24
|
-
"name": "@edirect/oidc-client",
|
|
25
|
-
"targets": {
|
|
26
|
-
"build": {
|
|
27
|
-
"executor": "@nx/js:tsc",
|
|
28
|
-
"options": {
|
|
29
|
-
"main": "{workspaceRoot}/packages/edirect-oidc-client/src/index.ts",
|
|
30
|
-
"tsConfig": "{workspaceRoot}/packages/edirect-oidc-client/tsconfig.lib.json",
|
|
31
|
-
"outputPath": "{workspaceRoot}/packages/edirect-oidc-client/dist",
|
|
32
|
-
"assets": [
|
|
33
|
-
"{workspaceRoot}/packages/edirect-oidc-client/package.json",
|
|
34
|
-
"{workspaceRoot}/packages/edirect-oidc-client/README.md"
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
42
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
43
|
-
"build": "pnpm run build:cjs && pnpm run build:esm"
|
|
44
|
-
}
|
|
22
|
+
"type": "commonjs"
|
|
45
23
|
}
|
package/dist/README.md
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# @edirect/oidc-client
|
|
2
|
-
|
|
3
|
-
OpenID Connect client for eDirect applications. Supports three OAuth2 grant types — `password`, `client_credentials`, and `sso` — with a uniform API for acquiring and refreshing tokens.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Three grant types: `password`, `client_credentials`, `sso`
|
|
8
|
-
- Uniform `getAccessToken()` and `getRefreshToken()` API across all grant types
|
|
9
|
-
- OIDC provider discovery via configurable `baseUrl` and `oidcPath`
|
|
10
|
-
- Token set parsing utilities
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
pnpm add @edirect/oidc-client
|
|
16
|
-
# or
|
|
17
|
-
npm install @edirect/oidc-client
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
|
|
22
|
-
### Password Grant (username + password)
|
|
23
|
-
|
|
24
|
-
Used when the application authenticates on behalf of a user:
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
import OidcClient from '@edirect/oidc-client';
|
|
28
|
-
|
|
29
|
-
const client = await OidcClient({
|
|
30
|
-
grantType: 'password',
|
|
31
|
-
baseUrl: process.env.OIDC_PROVIDER_URL, // e.g., 'https://keycloak.example.com'
|
|
32
|
-
oidcPath: process.env.OIDC_PROVIDER_PATH, // e.g., '/realms/my-realm'
|
|
33
|
-
clientId: process.env.OIDC_CLIENT_ID,
|
|
34
|
-
clientSecret: process.env.OIDC_CLIENT_SECRET,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Acquire access token
|
|
38
|
-
const tokenSet = await client.getAccessToken({
|
|
39
|
-
username: process.env.OIDC_USERNAME,
|
|
40
|
-
password: process.env.OIDC_PASSWORD,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
console.log(tokenSet.access_token);
|
|
44
|
-
console.log(tokenSet.expires_in);
|
|
45
|
-
|
|
46
|
-
// Refresh token (not available for client_credentials)
|
|
47
|
-
const refreshed = await client.getRefreshToken(tokenSet);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Client Credentials Grant (service-to-service)
|
|
51
|
-
|
|
52
|
-
Used for machine-to-machine authentication:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
import OidcClient from '@edirect/oidc-client';
|
|
56
|
-
|
|
57
|
-
const client = await OidcClient({
|
|
58
|
-
grantType: 'client_credentials',
|
|
59
|
-
baseUrl: process.env.OIDC_PROVIDER_URL,
|
|
60
|
-
oidcPath: process.env.OIDC_PROVIDER_PATH,
|
|
61
|
-
clientId: process.env.OIDC_CLIENT_ID,
|
|
62
|
-
clientSecret: process.env.OIDC_CLIENT_SECRET,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// No login data required for client_credentials
|
|
66
|
-
const tokenSet = await client.getAccessToken();
|
|
67
|
-
console.log(tokenSet.access_token);
|
|
68
|
-
|
|
69
|
-
// Note: getRefreshToken is not applicable to client_credentials
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### SSO Grant
|
|
73
|
-
|
|
74
|
-
Used for SSO-based authentication flows:
|
|
75
|
-
|
|
76
|
-
```ts
|
|
77
|
-
const client = await OidcClient({
|
|
78
|
-
grantType: 'sso',
|
|
79
|
-
baseUrl: process.env.OIDC_PROVIDER_URL,
|
|
80
|
-
oidcPath: process.env.OIDC_PROVIDER_PATH,
|
|
81
|
-
clientId: process.env.OIDC_CLIENT_ID,
|
|
82
|
-
clientSecret: process.env.OIDC_CLIENT_SECRET,
|
|
83
|
-
redirectUri: process.env.OIDC_CALLBACK_URL,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const tokenSet = await client.getAccessToken({ code: authorizationCode });
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## API
|
|
90
|
-
|
|
91
|
-
### `OidcClient(params: Connect): Promise<OidcConnect>`
|
|
92
|
-
|
|
93
|
-
Factory function that initializes the OIDC client for the specified grant type.
|
|
94
|
-
|
|
95
|
-
| Parameter | Type | Description |
|
|
96
|
-
| -------------- | --------------------------------------------- | ------------------------------------------ |
|
|
97
|
-
| `grantType` | `'password' \| 'client_credentials' \| 'sso'` | OAuth2 grant type |
|
|
98
|
-
| `baseUrl` | `string` | OIDC provider base URL |
|
|
99
|
-
| `oidcPath` | `string` | OIDC realm path (e.g., `/realms/my-realm`) |
|
|
100
|
-
| `clientId` | `string` | Client ID registered in the OIDC provider |
|
|
101
|
-
| `clientSecret` | `string` | Client secret |
|
|
102
|
-
| `redirectUri` | `string` | Callback URL (for `sso` grant) |
|
|
103
|
-
|
|
104
|
-
### Client Methods
|
|
105
|
-
|
|
106
|
-
| Method | Signature | Description |
|
|
107
|
-
| ----------------- | ----------------------------------- | ------------------------------------------------------------ |
|
|
108
|
-
| `getAccessToken` | `(loginData?) => Promise<TokenSet>` | Acquire an access token |
|
|
109
|
-
| `getRefreshToken` | `(tokenSet) => Promise<TokenSet>` | Refresh an existing token set (not for `client_credentials`) |
|
|
110
|
-
|
|
111
|
-
### `TokenSet`
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
interface TokenSet {
|
|
115
|
-
access_token: string;
|
|
116
|
-
token_type: string;
|
|
117
|
-
expires_in: number;
|
|
118
|
-
refresh_token?: string; // not present for client_credentials
|
|
119
|
-
refresh_expires_in?: number;
|
|
120
|
-
id_token?: string;
|
|
121
|
-
session_state?: string;
|
|
122
|
-
scope?: string;
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## Environment Variables
|
|
127
|
-
|
|
128
|
-
| Variable | Description |
|
|
129
|
-
| -------------------- | ------------------------------------------------------------- |
|
|
130
|
-
| `OIDC_PROVIDER_URL` | OIDC provider base URL (e.g., `https://keycloak.example.com`) |
|
|
131
|
-
| `OIDC_PROVIDER_PATH` | OIDC realm path (e.g., `/realms/my-realm`) |
|
|
132
|
-
| `OIDC_CLIENT_ID` | Client ID |
|
|
133
|
-
| `OIDC_CLIENT_SECRET` | Client secret |
|
|
134
|
-
| `OIDC_USERNAME` | Username (for `password` grant) |
|
|
135
|
-
| `OIDC_PASSWORD` | Password (for `password` grant) |
|
|
136
|
-
| `OIDC_CALLBACK_URL` | Redirect URI (for `sso` grant) |
|
package/dist/package.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@edirect/oidc-client",
|
|
3
|
-
"version": "11.0.65",
|
|
4
|
-
"main": "./dist/cjs/index.js",
|
|
5
|
-
"module": "./dist/esm/index.js",
|
|
6
|
-
"types": "./dist/types/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"require": "./dist/cjs/index.js",
|
|
10
|
-
"import": "./dist/esm/index.js",
|
|
11
|
-
"types": "./dist/types/index.d.ts"
|
|
12
|
-
},
|
|
13
|
-
"./package.json": "./package.json"
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"openid-client": "^6.8.6",
|
|
20
|
-
"tslib": "^2.8.1"
|
|
21
|
-
},
|
|
22
|
-
"type": "commonjs"
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"5.9.3"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|