thunderid-nestjs 0.1.0
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 +202 -0
- package/README.md +118 -0
- package/dist/ThunderIDModule.d.ts +42 -0
- package/dist/ThunderIDModule.d.ts.map +1 -0
- package/dist/ThunderIDService.d.ts +80 -0
- package/dist/ThunderIDService.d.ts.map +1 -0
- package/dist/cjs/index.cjs +266 -0
- package/dist/constants/InjectionTokens.d.ts +20 -0
- package/dist/constants/InjectionTokens.d.ts.map +1 -0
- package/dist/decorators/CurrentUser.d.ts +26 -0
- package/dist/decorators/CurrentUser.d.ts.map +1 -0
- package/dist/guards/ThunderIDGuard.d.ts +41 -0
- package/dist/guards/ThunderIDGuard.d.ts.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +233 -0
- package/dist/models/config.d.ts +39 -0
- package/dist/models/config.d.ts.map +1 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2026 Srinu Desetti (@webdevelopersrinu)
|
|
190
|
+
Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com) (original ThunderID NestJS SDK)
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# thunderid-nestjs
|
|
2
|
+
|
|
3
|
+
NestJS SDK for [ThunderID](https://github.com/thunder-id/thunderid). Built on top of
|
|
4
|
+
[`@thunderid/express`](https://www.npmjs.com/package/@thunderid/express) — works with NestJS applications running on
|
|
5
|
+
the default Express platform.
|
|
6
|
+
|
|
7
|
+
Community-maintained — ported from [thunder-id/javascript-sdks#26](https://github.com/thunder-id/javascript-sdks/pull/26).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install thunderid-nestjs cookie-parser
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
Register `cookie-parser` and the ThunderID module:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// main.ts
|
|
21
|
+
import cookieParser from 'cookie-parser';
|
|
22
|
+
|
|
23
|
+
const app = await NestFactory.create(AppModule);
|
|
24
|
+
app.use(cookieParser());
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// app.module.ts
|
|
29
|
+
import {ThunderIDModule} from 'thunderid-nestjs';
|
|
30
|
+
|
|
31
|
+
@Module({
|
|
32
|
+
imports: [
|
|
33
|
+
ThunderIDModule.forRoot({
|
|
34
|
+
clientId: process.env.THUNDERID_CLIENT_ID,
|
|
35
|
+
baseUrl: process.env.THUNDERID_BASE_URL,
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
})
|
|
39
|
+
export class AppModule {}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The module is global — `ThunderIDService` and `ThunderIDGuard` are injectable everywhere.
|
|
43
|
+
|
|
44
|
+
## Sign-in / sign-out routes
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import {Request, Response} from 'express';
|
|
48
|
+
import {ThunderIDService} from 'thunderid-nestjs';
|
|
49
|
+
|
|
50
|
+
@Controller()
|
|
51
|
+
export class AuthController {
|
|
52
|
+
constructor(private readonly thunderID: ThunderIDService) {}
|
|
53
|
+
|
|
54
|
+
@Get('login')
|
|
55
|
+
async login(@Req() req: Request, @Res() res: Response) {
|
|
56
|
+
const tokens = await this.thunderID.signIn(req, res);
|
|
57
|
+
if (tokens.accessToken || tokens.idToken) {
|
|
58
|
+
res.redirect('/');
|
|
59
|
+
}
|
|
60
|
+
// If no tokens were returned, signIn has already redirected the
|
|
61
|
+
// response to the ThunderID sign-in page.
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Get('logout')
|
|
65
|
+
async logout(@Req() req: Request, @Res() res: Response) {
|
|
66
|
+
if (this.thunderID.isSignOutSuccess(req)) {
|
|
67
|
+
res.redirect('/');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await this.thunderID.signOut(req, res);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Protecting routes
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import {CurrentUser, ThunderIDGuard, User} from 'thunderid-nestjs';
|
|
79
|
+
|
|
80
|
+
@Controller()
|
|
81
|
+
export class ProfileController {
|
|
82
|
+
@UseGuards(ThunderIDGuard)
|
|
83
|
+
@Get('profile')
|
|
84
|
+
profile(@CurrentUser() user: User) {
|
|
85
|
+
return user;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`ThunderIDGuard` returns `401 Unauthorized` for requests without a valid session. `@CurrentUser()` resolves the
|
|
91
|
+
authenticated user attached by the guard.
|
|
92
|
+
|
|
93
|
+
## API
|
|
94
|
+
|
|
95
|
+
| Export | Description |
|
|
96
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
97
|
+
| `ThunderIDModule.forRoot(config)` | Global module; accepts `ThunderIDNestConfig` (same shape as the Node SDK config) |
|
|
98
|
+
| `ThunderIDService` | `signIn(req, res)`, `signOut(req, res)`, `isSignOutSuccess(req)`, `isSignedIn(req)`, `getUser(req)`, `getClient()` |
|
|
99
|
+
| `ThunderIDGuard` | Route guard that blocks unauthenticated requests |
|
|
100
|
+
| `@CurrentUser()` | Param decorator resolving the authenticated `User` (requires `ThunderIDGuard`) |
|
|
101
|
+
|
|
102
|
+
Everything from `@thunderid/express` (and transitively `@thunderid/node` / `@thunderid/javascript`) is re-exported.
|
|
103
|
+
|
|
104
|
+
## Contributing
|
|
105
|
+
|
|
106
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
107
|
+
|
|
108
|
+
## Contributors
|
|
109
|
+
|
|
110
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
111
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
112
|
+
|
|
113
|
+
Thanks goes to these people. Add yourself by commenting on your merged PR:
|
|
114
|
+
`@all-contributors please add @<username> for code`.
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
Apache-2.0
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { DynamicModule } from '@nestjs/common';
|
|
19
|
+
import { ThunderIDNestConfig } from './models/config';
|
|
20
|
+
/**
|
|
21
|
+
* ThunderID module for NestJS. Register once in the root module:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* @Module({
|
|
25
|
+
* imports: [
|
|
26
|
+
* ThunderIDModule.forRoot({
|
|
27
|
+
* clientId: process.env.THUNDERID_CLIENT_ID,
|
|
28
|
+
* baseUrl: process.env.THUNDERID_BASE_URL,
|
|
29
|
+
* }),
|
|
30
|
+
* ],
|
|
31
|
+
* })
|
|
32
|
+
* export class AppModule {}
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* The module is global — `ThunderIDService` and `ThunderIDGuard` are
|
|
36
|
+
* injectable everywhere without re-importing.
|
|
37
|
+
*/
|
|
38
|
+
declare class ThunderIDModule {
|
|
39
|
+
static forRoot(config: ThunderIDNestConfig): DynamicModule;
|
|
40
|
+
}
|
|
41
|
+
export default ThunderIDModule;
|
|
42
|
+
//# sourceMappingURL=ThunderIDModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThunderIDModule.d.ts","sourceRoot":"","sources":["../src/ThunderIDModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,aAAa,EAAS,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAGpD;;;;;;;;;;;;;;;;;GAiBG;AACH,cACM,eAAe;WACL,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa;CAQlE;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { ThunderIDExpressClient, TokenResponse, User } from '@thunderid/express';
|
|
19
|
+
import type express from 'express';
|
|
20
|
+
import { ThunderIDNestConfig } from './models/config';
|
|
21
|
+
/**
|
|
22
|
+
* Injectable service exposing ThunderID authentication to NestJS applications.
|
|
23
|
+
*
|
|
24
|
+
* Register it once with `ThunderIDModule.forRoot(config)` and inject it into
|
|
25
|
+
* controllers:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* @Controller()
|
|
29
|
+
* export class AuthController {
|
|
30
|
+
* constructor(private readonly thunderID: ThunderIDService) {}
|
|
31
|
+
*
|
|
32
|
+
* @Get('login')
|
|
33
|
+
* async login(@Req() req: Request, @Res() res: Response) {
|
|
34
|
+
* const tokens = await this.thunderID.signIn(req, res);
|
|
35
|
+
* if (tokens.accessToken || tokens.idToken) res.redirect('/');
|
|
36
|
+
* // If no tokens were returned, signIn has already redirected the
|
|
37
|
+
* // response to the ThunderID sign-in page.
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* Requires `cookie-parser` middleware to be registered on the application.
|
|
43
|
+
*/
|
|
44
|
+
declare class ThunderIDService {
|
|
45
|
+
private readonly config;
|
|
46
|
+
private readonly client;
|
|
47
|
+
private initPromise;
|
|
48
|
+
constructor(config: ThunderIDNestConfig);
|
|
49
|
+
/** The underlying `ThunderIDExpressClient` for advanced use cases. */
|
|
50
|
+
getClient(): ThunderIDExpressClient;
|
|
51
|
+
private static getSessionId;
|
|
52
|
+
private ensureInitialized;
|
|
53
|
+
/**
|
|
54
|
+
* Handles the sign-in path.
|
|
55
|
+
*
|
|
56
|
+
* - If the request has no `?code` query param, initiates the OAuth 2.0
|
|
57
|
+
* redirect (the response is sent by the SDK — do not write to it after).
|
|
58
|
+
* - If the request has `?code`, exchanges the authorization code for tokens,
|
|
59
|
+
* sets the session cookie, and returns the token response.
|
|
60
|
+
*/
|
|
61
|
+
signIn(req: express.Request, res: express.Response, signInOptions?: Record<string, string | boolean>): Promise<TokenResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Handles the sign-out path: clears the session cookie and redirects the
|
|
64
|
+
* response to the identity provider's end-session endpoint.
|
|
65
|
+
*
|
|
66
|
+
* Check {@link isSignOutSuccess} first to detect the identity provider's
|
|
67
|
+
* redirect back after a completed sign-out.
|
|
68
|
+
*
|
|
69
|
+
* @throws ThunderIDRuntimeError when the request has no session cookie.
|
|
70
|
+
*/
|
|
71
|
+
signOut(req: express.Request, res: express.Response): Promise<void>;
|
|
72
|
+
/** Whether the request is the identity provider's redirect back after a completed sign-out. */
|
|
73
|
+
isSignOutSuccess(req: express.Request): boolean;
|
|
74
|
+
/** Whether the request carries a valid ThunderID session. */
|
|
75
|
+
isSignedIn(req: express.Request): Promise<boolean>;
|
|
76
|
+
/** Returns the authenticated user for the request's session, or `undefined`. */
|
|
77
|
+
getUser(req: express.Request): Promise<User | undefined>;
|
|
78
|
+
}
|
|
79
|
+
export default ThunderIDService;
|
|
80
|
+
//# sourceMappingURL=ThunderIDService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThunderIDService.d.ts","sourceRoot":"","sources":["../src/ThunderIDService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAEL,sBAAsB,EAEtB,aAAa,EACb,IAAI,EACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,cACM,gBAAgB;IAIyB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHpE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAC/E,OAAO,CAAC,WAAW,CAA+B;gBAEY,MAAM,EAAE,mBAAmB;IAEzF,sEAAsE;IAC/D,SAAS,IAAI,sBAAsB;IAI1C,OAAO,CAAC,MAAM,CAAC,YAAY;IAK3B,OAAO,CAAC,iBAAiB;IAmBzB;;;;;;;OAOG;IACU,MAAM,CACjB,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,EACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAC/C,OAAO,CAAC,aAAa,CAAC;IAKzB;;;;;;;;OAQG;IACU,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBhF,+FAA+F;IACxF,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO;IAKtD,6DAA6D;IAChD,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAW/D,gFAAgF;IACnE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;CAItE;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let __nestjs_common = require("@nestjs/common");
|
|
25
|
+
__nestjs_common = __toESM(__nestjs_common);
|
|
26
|
+
let __thunderid_express = require("@thunderid/express");
|
|
27
|
+
__thunderid_express = __toESM(__thunderid_express);
|
|
28
|
+
|
|
29
|
+
//#region src/constants/InjectionTokens.ts
|
|
30
|
+
/**
|
|
31
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
32
|
+
*
|
|
33
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
34
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
35
|
+
* in compliance with the License.
|
|
36
|
+
* You may obtain a copy of the License at
|
|
37
|
+
*
|
|
38
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
39
|
+
*
|
|
40
|
+
* Unless required by applicable law or agreed to in writing,
|
|
41
|
+
* software distributed under the License is distributed on an
|
|
42
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
43
|
+
* KIND, either express or implied. See the License for the
|
|
44
|
+
* specific language governing permissions and limitations
|
|
45
|
+
* under the License.
|
|
46
|
+
*/
|
|
47
|
+
/** Injection token for the ThunderID configuration passed to `ThunderIDModule.forRoot()`. */
|
|
48
|
+
const THUNDERID_CONFIG = "THUNDERID_CONFIG";
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/decorateParam.js
|
|
52
|
+
function __decorateParam(paramIndex, decorator) {
|
|
53
|
+
return function(target, key) {
|
|
54
|
+
decorator(target, key, paramIndex);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
|
|
60
|
+
function __decorate(decorators, target, key, desc) {
|
|
61
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
62
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
63
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
64
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/ThunderIDService.ts
|
|
69
|
+
var _ThunderIDService;
|
|
70
|
+
/**
|
|
71
|
+
* Injectable service exposing ThunderID authentication to NestJS applications.
|
|
72
|
+
*
|
|
73
|
+
* Register it once with `ThunderIDModule.forRoot(config)` and inject it into
|
|
74
|
+
* controllers:
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* @Controller()
|
|
78
|
+
* export class AuthController {
|
|
79
|
+
* constructor(private readonly thunderID: ThunderIDService) {}
|
|
80
|
+
*
|
|
81
|
+
* @Get('login')
|
|
82
|
+
* async login(@Req() req: Request, @Res() res: Response) {
|
|
83
|
+
* const tokens = await this.thunderID.signIn(req, res);
|
|
84
|
+
* if (tokens.accessToken || tokens.idToken) res.redirect('/');
|
|
85
|
+
* // If no tokens were returned, signIn has already redirected the
|
|
86
|
+
* // response to the ThunderID sign-in page.
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* Requires `cookie-parser` middleware to be registered on the application.
|
|
92
|
+
*/
|
|
93
|
+
let ThunderIDService = _ThunderIDService = class ThunderIDService$1 {
|
|
94
|
+
client = new __thunderid_express.ThunderIDExpressClient();
|
|
95
|
+
initPromise;
|
|
96
|
+
constructor(config) {
|
|
97
|
+
this.config = config;
|
|
98
|
+
}
|
|
99
|
+
/** The underlying `ThunderIDExpressClient` for advanced use cases. */
|
|
100
|
+
getClient() {
|
|
101
|
+
return this.client;
|
|
102
|
+
}
|
|
103
|
+
static getSessionId(req) {
|
|
104
|
+
return req.cookies?.[__thunderid_express.SESSION_COOKIE_NAME];
|
|
105
|
+
}
|
|
106
|
+
ensureInitialized(req) {
|
|
107
|
+
if (this.initPromise === void 0) {
|
|
108
|
+
const origin = `${req.protocol}://${req.get("host")}`;
|
|
109
|
+
this.initPromise = this.client.initialize({
|
|
110
|
+
...this.config,
|
|
111
|
+
afterSignInUrl: this.config.afterSignInUrl ?? `${origin}/login`,
|
|
112
|
+
afterSignOutUrl: this.config.afterSignOutUrl ?? `${origin}/logout`
|
|
113
|
+
}).catch((error) => {
|
|
114
|
+
this.initPromise = void 0;
|
|
115
|
+
throw error;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return this.initPromise;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Handles the sign-in path.
|
|
122
|
+
*
|
|
123
|
+
* - If the request has no `?code` query param, initiates the OAuth 2.0
|
|
124
|
+
* redirect (the response is sent by the SDK — do not write to it after).
|
|
125
|
+
* - If the request has `?code`, exchanges the authorization code for tokens,
|
|
126
|
+
* sets the session cookie, and returns the token response.
|
|
127
|
+
*/
|
|
128
|
+
async signIn(req, res, signInOptions) {
|
|
129
|
+
await this.ensureInitialized(req);
|
|
130
|
+
return this.client.signIn(req, res, () => void 0, signInOptions ?? this.config.signInOptions);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Handles the sign-out path: clears the session cookie and redirects the
|
|
134
|
+
* response to the identity provider's end-session endpoint.
|
|
135
|
+
*
|
|
136
|
+
* Check {@link isSignOutSuccess} first to detect the identity provider's
|
|
137
|
+
* redirect back after a completed sign-out.
|
|
138
|
+
*
|
|
139
|
+
* @throws ThunderIDRuntimeError when the request has no session cookie.
|
|
140
|
+
*/
|
|
141
|
+
async signOut(req, res) {
|
|
142
|
+
await this.ensureInitialized(req);
|
|
143
|
+
const sessionId = _ThunderIDService.getSessionId(req);
|
|
144
|
+
if (!sessionId) throw new __thunderid_express.ThunderIDRuntimeError("No cookie found in the request", "NESTJS-SERVICE-SO-NF01", "nestjs");
|
|
145
|
+
const signOutURL = await this.client.signOut(sessionId);
|
|
146
|
+
if (signOutURL) {
|
|
147
|
+
res.cookie(__thunderid_express.SESSION_COOKIE_NAME, "", { maxAge: 0 });
|
|
148
|
+
res.redirect(signOutURL);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Whether the request is the identity provider's redirect back after a completed sign-out. */
|
|
152
|
+
isSignOutSuccess(req) {
|
|
153
|
+
const state = req.query["state"];
|
|
154
|
+
return typeof state === "string" && state === "sign_out_success";
|
|
155
|
+
}
|
|
156
|
+
/** Whether the request carries a valid ThunderID session. */
|
|
157
|
+
async isSignedIn(req) {
|
|
158
|
+
await this.ensureInitialized(req);
|
|
159
|
+
const sessionId = _ThunderIDService.getSessionId(req);
|
|
160
|
+
if (!sessionId) return false;
|
|
161
|
+
return await this.client.isSignedIn(sessionId) ?? false;
|
|
162
|
+
}
|
|
163
|
+
/** Returns the authenticated user for the request's session, or `undefined`. */
|
|
164
|
+
async getUser(req) {
|
|
165
|
+
await this.ensureInitialized(req);
|
|
166
|
+
return this.client.getUserFromRequest(req);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
ThunderIDService = _ThunderIDService = __decorate([(0, __nestjs_common.Injectable)(), __decorateParam(0, (0, __nestjs_common.Inject)(THUNDERID_CONFIG))], ThunderIDService);
|
|
170
|
+
var ThunderIDService_default = ThunderIDService;
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/guards/ThunderIDGuard.ts
|
|
174
|
+
/**
|
|
175
|
+
* Guard that blocks unauthenticated requests — the NestJS equivalent of the
|
|
176
|
+
* Express SDK's `protect()` middleware.
|
|
177
|
+
*
|
|
178
|
+
* On success, the authenticated user is attached to the request and can be
|
|
179
|
+
* read with the `@CurrentUser()` param decorator.
|
|
180
|
+
*
|
|
181
|
+
* ```ts
|
|
182
|
+
* @UseGuards(ThunderIDGuard)
|
|
183
|
+
* @Get('profile')
|
|
184
|
+
* profile(@CurrentUser() user: User) {
|
|
185
|
+
* return user;
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
let ThunderIDGuard = class ThunderIDGuard$1 {
|
|
190
|
+
constructor(thunderID) {
|
|
191
|
+
this.thunderID = thunderID;
|
|
192
|
+
}
|
|
193
|
+
async canActivate(context) {
|
|
194
|
+
const req = context.switchToHttp().getRequest();
|
|
195
|
+
if (!await this.thunderID.isSignedIn(req)) throw new __nestjs_common.UnauthorizedException();
|
|
196
|
+
req.thunderIDUser = await this.thunderID.getUser(req);
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
ThunderIDGuard = __decorate([(0, __nestjs_common.Injectable)(), __decorateParam(0, (0, __nestjs_common.Inject)(ThunderIDService_default))], ThunderIDGuard);
|
|
201
|
+
var ThunderIDGuard_default = ThunderIDGuard;
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/ThunderIDModule.ts
|
|
205
|
+
var _ThunderIDModule;
|
|
206
|
+
/**
|
|
207
|
+
* ThunderID module for NestJS. Register once in the root module:
|
|
208
|
+
*
|
|
209
|
+
* ```ts
|
|
210
|
+
* @Module({
|
|
211
|
+
* imports: [
|
|
212
|
+
* ThunderIDModule.forRoot({
|
|
213
|
+
* clientId: process.env.THUNDERID_CLIENT_ID,
|
|
214
|
+
* baseUrl: process.env.THUNDERID_BASE_URL,
|
|
215
|
+
* }),
|
|
216
|
+
* ],
|
|
217
|
+
* })
|
|
218
|
+
* export class AppModule {}
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* The module is global — `ThunderIDService` and `ThunderIDGuard` are
|
|
222
|
+
* injectable everywhere without re-importing.
|
|
223
|
+
*/
|
|
224
|
+
let ThunderIDModule = _ThunderIDModule = class ThunderIDModule$1 {
|
|
225
|
+
static forRoot(config) {
|
|
226
|
+
return {
|
|
227
|
+
exports: [ThunderIDService_default, ThunderIDGuard_default],
|
|
228
|
+
global: true,
|
|
229
|
+
module: _ThunderIDModule,
|
|
230
|
+
providers: [
|
|
231
|
+
{
|
|
232
|
+
provide: THUNDERID_CONFIG,
|
|
233
|
+
useValue: config
|
|
234
|
+
},
|
|
235
|
+
ThunderIDService_default,
|
|
236
|
+
ThunderIDGuard_default
|
|
237
|
+
]
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
ThunderIDModule = _ThunderIDModule = __decorate([(0, __nestjs_common.Module)({})], ThunderIDModule);
|
|
242
|
+
var ThunderIDModule_default = ThunderIDModule;
|
|
243
|
+
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/decorators/CurrentUser.ts
|
|
246
|
+
/**
|
|
247
|
+
* Param decorator that resolves the authenticated ThunderID user.
|
|
248
|
+
*
|
|
249
|
+
* Requires `ThunderIDGuard` on the route — the guard attaches the user to the
|
|
250
|
+
* request; without it this resolves to `undefined`.
|
|
251
|
+
*/
|
|
252
|
+
const CurrentUser = (0, __nestjs_common.createParamDecorator)((data, context) => context.switchToHttp().getRequest().thunderIDUser);
|
|
253
|
+
var CurrentUser_default = CurrentUser;
|
|
254
|
+
|
|
255
|
+
//#endregion
|
|
256
|
+
exports.CurrentUser = CurrentUser_default;
|
|
257
|
+
exports.THUNDERID_CONFIG = THUNDERID_CONFIG;
|
|
258
|
+
exports.ThunderIDGuard = ThunderIDGuard_default;
|
|
259
|
+
exports.ThunderIDModule = ThunderIDModule_default;
|
|
260
|
+
exports.ThunderIDService = ThunderIDService_default;
|
|
261
|
+
Object.keys(__thunderid_express).forEach(function (k) {
|
|
262
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function () { return __thunderid_express[k]; }
|
|
265
|
+
});
|
|
266
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/** Injection token for the ThunderID configuration passed to `ThunderIDModule.forRoot()`. */
|
|
19
|
+
export declare const THUNDERID_CONFIG = "THUNDERID_CONFIG";
|
|
20
|
+
//# sourceMappingURL=InjectionTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InjectionTokens.d.ts","sourceRoot":"","sources":["../../src/constants/InjectionTokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,6FAA6F;AAC7F,eAAO,MAAM,gBAAgB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Param decorator that resolves the authenticated ThunderID user.
|
|
20
|
+
*
|
|
21
|
+
* Requires `ThunderIDGuard` on the route — the guard attaches the user to the
|
|
22
|
+
* request; without it this resolves to `undefined`.
|
|
23
|
+
*/
|
|
24
|
+
declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
25
|
+
export default CurrentUser;
|
|
26
|
+
//# sourceMappingURL=CurrentUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrentUser.d.ts","sourceRoot":"","sources":["../../src/decorators/CurrentUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;;;;GAKG;AACH,QAAA,MAAM,WAAW,mDAGhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
19
|
+
import ThunderIDService from '../ThunderIDService';
|
|
20
|
+
/**
|
|
21
|
+
* Guard that blocks unauthenticated requests — the NestJS equivalent of the
|
|
22
|
+
* Express SDK's `protect()` middleware.
|
|
23
|
+
*
|
|
24
|
+
* On success, the authenticated user is attached to the request and can be
|
|
25
|
+
* read with the `@CurrentUser()` param decorator.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* @UseGuards(ThunderIDGuard)
|
|
29
|
+
* @Get('profile')
|
|
30
|
+
* profile(@CurrentUser() user: User) {
|
|
31
|
+
* return user;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare class ThunderIDGuard implements CanActivate {
|
|
36
|
+
private readonly thunderID;
|
|
37
|
+
constructor(thunderID: ThunderIDService);
|
|
38
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
export default ThunderIDGuard;
|
|
41
|
+
//# sourceMappingURL=ThunderIDGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThunderIDGuard.d.ts","sourceRoot":"","sources":["../../src/guards/ThunderIDGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAA4C,MAAM,gBAAgB,CAAC;AAExG,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AACH,cACM,cAAe,YAAW,WAAW;IACI,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,gBAAgB;IAE5E,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAWtE;AAED,eAAe,cAAc,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
export { default as ThunderIDModule } from './ThunderIDModule';
|
|
19
|
+
export { default as ThunderIDService } from './ThunderIDService';
|
|
20
|
+
export { default as ThunderIDGuard } from './guards/ThunderIDGuard';
|
|
21
|
+
export { default as CurrentUser } from './decorators/CurrentUser';
|
|
22
|
+
export type { ThunderIDNestConfig, ThunderIDRequest } from './models/config';
|
|
23
|
+
export { THUNDERID_CONFIG } from './constants/InjectionTokens';
|
|
24
|
+
export * from '@thunderid/express';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAGlE,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAGhE,YAAY,EAAC,mBAAmB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAG3E,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAG7D,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { Inject, Injectable, Module, UnauthorizedException, createParamDecorator } from "@nestjs/common";
|
|
2
|
+
import { SESSION_COOKIE_NAME, ThunderIDExpressClient, ThunderIDRuntimeError } from "@thunderid/express";
|
|
3
|
+
|
|
4
|
+
export * from "@thunderid/express"
|
|
5
|
+
|
|
6
|
+
//#region src/constants/InjectionTokens.ts
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
9
|
+
*
|
|
10
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
11
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
12
|
+
* in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing,
|
|
18
|
+
* software distributed under the License is distributed on an
|
|
19
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
* KIND, either express or implied. See the License for the
|
|
21
|
+
* specific language governing permissions and limitations
|
|
22
|
+
* under the License.
|
|
23
|
+
*/
|
|
24
|
+
/** Injection token for the ThunderID configuration passed to `ThunderIDModule.forRoot()`. */
|
|
25
|
+
const THUNDERID_CONFIG = "THUNDERID_CONFIG";
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/decorateParam.js
|
|
29
|
+
function __decorateParam(paramIndex, decorator) {
|
|
30
|
+
return function(target, key) {
|
|
31
|
+
decorator(target, key, paramIndex);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
|
|
37
|
+
function __decorate(decorators, target, key, desc) {
|
|
38
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
39
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
40
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
41
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/ThunderIDService.ts
|
|
46
|
+
var _ThunderIDService;
|
|
47
|
+
/**
|
|
48
|
+
* Injectable service exposing ThunderID authentication to NestJS applications.
|
|
49
|
+
*
|
|
50
|
+
* Register it once with `ThunderIDModule.forRoot(config)` and inject it into
|
|
51
|
+
* controllers:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* @Controller()
|
|
55
|
+
* export class AuthController {
|
|
56
|
+
* constructor(private readonly thunderID: ThunderIDService) {}
|
|
57
|
+
*
|
|
58
|
+
* @Get('login')
|
|
59
|
+
* async login(@Req() req: Request, @Res() res: Response) {
|
|
60
|
+
* const tokens = await this.thunderID.signIn(req, res);
|
|
61
|
+
* if (tokens.accessToken || tokens.idToken) res.redirect('/');
|
|
62
|
+
* // If no tokens were returned, signIn has already redirected the
|
|
63
|
+
* // response to the ThunderID sign-in page.
|
|
64
|
+
* }
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* Requires `cookie-parser` middleware to be registered on the application.
|
|
69
|
+
*/
|
|
70
|
+
let ThunderIDService = _ThunderIDService = class ThunderIDService$1 {
|
|
71
|
+
client = new ThunderIDExpressClient();
|
|
72
|
+
initPromise;
|
|
73
|
+
constructor(config) {
|
|
74
|
+
this.config = config;
|
|
75
|
+
}
|
|
76
|
+
/** The underlying `ThunderIDExpressClient` for advanced use cases. */
|
|
77
|
+
getClient() {
|
|
78
|
+
return this.client;
|
|
79
|
+
}
|
|
80
|
+
static getSessionId(req) {
|
|
81
|
+
return req.cookies?.[SESSION_COOKIE_NAME];
|
|
82
|
+
}
|
|
83
|
+
ensureInitialized(req) {
|
|
84
|
+
if (this.initPromise === void 0) {
|
|
85
|
+
const origin = `${req.protocol}://${req.get("host")}`;
|
|
86
|
+
this.initPromise = this.client.initialize({
|
|
87
|
+
...this.config,
|
|
88
|
+
afterSignInUrl: this.config.afterSignInUrl ?? `${origin}/login`,
|
|
89
|
+
afterSignOutUrl: this.config.afterSignOutUrl ?? `${origin}/logout`
|
|
90
|
+
}).catch((error) => {
|
|
91
|
+
this.initPromise = void 0;
|
|
92
|
+
throw error;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return this.initPromise;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Handles the sign-in path.
|
|
99
|
+
*
|
|
100
|
+
* - If the request has no `?code` query param, initiates the OAuth 2.0
|
|
101
|
+
* redirect (the response is sent by the SDK — do not write to it after).
|
|
102
|
+
* - If the request has `?code`, exchanges the authorization code for tokens,
|
|
103
|
+
* sets the session cookie, and returns the token response.
|
|
104
|
+
*/
|
|
105
|
+
async signIn(req, res, signInOptions) {
|
|
106
|
+
await this.ensureInitialized(req);
|
|
107
|
+
return this.client.signIn(req, res, () => void 0, signInOptions ?? this.config.signInOptions);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Handles the sign-out path: clears the session cookie and redirects the
|
|
111
|
+
* response to the identity provider's end-session endpoint.
|
|
112
|
+
*
|
|
113
|
+
* Check {@link isSignOutSuccess} first to detect the identity provider's
|
|
114
|
+
* redirect back after a completed sign-out.
|
|
115
|
+
*
|
|
116
|
+
* @throws ThunderIDRuntimeError when the request has no session cookie.
|
|
117
|
+
*/
|
|
118
|
+
async signOut(req, res) {
|
|
119
|
+
await this.ensureInitialized(req);
|
|
120
|
+
const sessionId = _ThunderIDService.getSessionId(req);
|
|
121
|
+
if (!sessionId) throw new ThunderIDRuntimeError("No cookie found in the request", "NESTJS-SERVICE-SO-NF01", "nestjs");
|
|
122
|
+
const signOutURL = await this.client.signOut(sessionId);
|
|
123
|
+
if (signOutURL) {
|
|
124
|
+
res.cookie(SESSION_COOKIE_NAME, "", { maxAge: 0 });
|
|
125
|
+
res.redirect(signOutURL);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Whether the request is the identity provider's redirect back after a completed sign-out. */
|
|
129
|
+
isSignOutSuccess(req) {
|
|
130
|
+
const state = req.query["state"];
|
|
131
|
+
return typeof state === "string" && state === "sign_out_success";
|
|
132
|
+
}
|
|
133
|
+
/** Whether the request carries a valid ThunderID session. */
|
|
134
|
+
async isSignedIn(req) {
|
|
135
|
+
await this.ensureInitialized(req);
|
|
136
|
+
const sessionId = _ThunderIDService.getSessionId(req);
|
|
137
|
+
if (!sessionId) return false;
|
|
138
|
+
return await this.client.isSignedIn(sessionId) ?? false;
|
|
139
|
+
}
|
|
140
|
+
/** Returns the authenticated user for the request's session, or `undefined`. */
|
|
141
|
+
async getUser(req) {
|
|
142
|
+
await this.ensureInitialized(req);
|
|
143
|
+
return this.client.getUserFromRequest(req);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
ThunderIDService = _ThunderIDService = __decorate([Injectable(), __decorateParam(0, Inject(THUNDERID_CONFIG))], ThunderIDService);
|
|
147
|
+
var ThunderIDService_default = ThunderIDService;
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/guards/ThunderIDGuard.ts
|
|
151
|
+
/**
|
|
152
|
+
* Guard that blocks unauthenticated requests — the NestJS equivalent of the
|
|
153
|
+
* Express SDK's `protect()` middleware.
|
|
154
|
+
*
|
|
155
|
+
* On success, the authenticated user is attached to the request and can be
|
|
156
|
+
* read with the `@CurrentUser()` param decorator.
|
|
157
|
+
*
|
|
158
|
+
* ```ts
|
|
159
|
+
* @UseGuards(ThunderIDGuard)
|
|
160
|
+
* @Get('profile')
|
|
161
|
+
* profile(@CurrentUser() user: User) {
|
|
162
|
+
* return user;
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
let ThunderIDGuard = class ThunderIDGuard$1 {
|
|
167
|
+
constructor(thunderID) {
|
|
168
|
+
this.thunderID = thunderID;
|
|
169
|
+
}
|
|
170
|
+
async canActivate(context) {
|
|
171
|
+
const req = context.switchToHttp().getRequest();
|
|
172
|
+
if (!await this.thunderID.isSignedIn(req)) throw new UnauthorizedException();
|
|
173
|
+
req.thunderIDUser = await this.thunderID.getUser(req);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
ThunderIDGuard = __decorate([Injectable(), __decorateParam(0, Inject(ThunderIDService_default))], ThunderIDGuard);
|
|
178
|
+
var ThunderIDGuard_default = ThunderIDGuard;
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/ThunderIDModule.ts
|
|
182
|
+
var _ThunderIDModule;
|
|
183
|
+
/**
|
|
184
|
+
* ThunderID module for NestJS. Register once in the root module:
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* @Module({
|
|
188
|
+
* imports: [
|
|
189
|
+
* ThunderIDModule.forRoot({
|
|
190
|
+
* clientId: process.env.THUNDERID_CLIENT_ID,
|
|
191
|
+
* baseUrl: process.env.THUNDERID_BASE_URL,
|
|
192
|
+
* }),
|
|
193
|
+
* ],
|
|
194
|
+
* })
|
|
195
|
+
* export class AppModule {}
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* The module is global — `ThunderIDService` and `ThunderIDGuard` are
|
|
199
|
+
* injectable everywhere without re-importing.
|
|
200
|
+
*/
|
|
201
|
+
let ThunderIDModule = _ThunderIDModule = class ThunderIDModule$1 {
|
|
202
|
+
static forRoot(config) {
|
|
203
|
+
return {
|
|
204
|
+
exports: [ThunderIDService_default, ThunderIDGuard_default],
|
|
205
|
+
global: true,
|
|
206
|
+
module: _ThunderIDModule,
|
|
207
|
+
providers: [
|
|
208
|
+
{
|
|
209
|
+
provide: THUNDERID_CONFIG,
|
|
210
|
+
useValue: config
|
|
211
|
+
},
|
|
212
|
+
ThunderIDService_default,
|
|
213
|
+
ThunderIDGuard_default
|
|
214
|
+
]
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
ThunderIDModule = _ThunderIDModule = __decorate([Module({})], ThunderIDModule);
|
|
219
|
+
var ThunderIDModule_default = ThunderIDModule;
|
|
220
|
+
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/decorators/CurrentUser.ts
|
|
223
|
+
/**
|
|
224
|
+
* Param decorator that resolves the authenticated ThunderID user.
|
|
225
|
+
*
|
|
226
|
+
* Requires `ThunderIDGuard` on the route — the guard attaches the user to the
|
|
227
|
+
* request; without it this resolves to `undefined`.
|
|
228
|
+
*/
|
|
229
|
+
const CurrentUser = createParamDecorator((data, context) => context.switchToHttp().getRequest().thunderIDUser);
|
|
230
|
+
var CurrentUser_default = CurrentUser;
|
|
231
|
+
|
|
232
|
+
//#endregion
|
|
233
|
+
export { CurrentUser_default as CurrentUser, THUNDERID_CONFIG, ThunderIDGuard_default as ThunderIDGuard, ThunderIDModule_default as ThunderIDModule, ThunderIDService_default as ThunderIDService };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { ThunderIDNodeConfig, User } from '@thunderid/express';
|
|
19
|
+
import type express from 'express';
|
|
20
|
+
/**
|
|
21
|
+
* Configuration type for the ThunderID NestJS SDK.
|
|
22
|
+
*
|
|
23
|
+
* `afterSignInUrl` and `afterSignOutUrl` are optional. When omitted, the SDK
|
|
24
|
+
* infers them from the first incoming request's origin combined with
|
|
25
|
+
* `/login` and `/logout` respectively.
|
|
26
|
+
*
|
|
27
|
+
* Unlike the Express SDK, response handling hooks (`onSignIn`, `onError`, …)
|
|
28
|
+
* are not part of the config — in NestJS the controller that calls
|
|
29
|
+
* `ThunderIDService` decides how to respond.
|
|
30
|
+
*/
|
|
31
|
+
export type ThunderIDNestConfig = ThunderIDNodeConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Express request extended with the ThunderID user attached by `ThunderIDGuard`.
|
|
34
|
+
*/
|
|
35
|
+
export interface ThunderIDRequest extends express.Request {
|
|
36
|
+
/** Authenticated user attached by `ThunderIDGuard`; read it with `@CurrentUser()`. */
|
|
37
|
+
thunderIDUser?: User;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,mBAAmB,EAAE,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,OAAO,CAAC,OAAO;IACvD,sFAAsF;IACtF,aAAa,CAAC,EAAE,IAAI,CAAC;CACtB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "thunderid-nestjs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NestJS SDK for ThunderID (community-maintained)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"thunderid",
|
|
7
|
+
"nestjs",
|
|
8
|
+
"server"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/webdevelopersrinu/thunderid-nestjs#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/webdevelopersrinu/thunderid-nestjs/issues"
|
|
13
|
+
},
|
|
14
|
+
"author": "srinu desetti",
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"module": "dist/index.js",
|
|
19
|
+
"commonjs": "dist/cjs/index.cjs",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/cjs/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"types": "dist/index.d.ts",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/webdevelopersrinu/thunderid-nestjs"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "npm run clean:dist && rolldown -c rolldown.config.js && tsc -p tsconfig.lib.json --emitDeclarationOnly --outDir dist",
|
|
39
|
+
"clean": "npm run clean:node_modules && npm run clean:dist",
|
|
40
|
+
"clean:dist": "rimraf dist",
|
|
41
|
+
"clean:node_modules": "rimraf node_modules",
|
|
42
|
+
"format:check": "prettier --check --cache .",
|
|
43
|
+
"format:fix": "prettier --write --cache .",
|
|
44
|
+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.cjs,.mjs",
|
|
45
|
+
"lint:fix": "eslint . --fix --ext .js,.jsx,.ts,.tsx,.cjs,.mjs",
|
|
46
|
+
"test": "vitest run --passWithNoTests",
|
|
47
|
+
"typecheck": "tsc -p tsconfig.lib.json",
|
|
48
|
+
"changeset": "changeset",
|
|
49
|
+
"version": "changeset version"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@changesets/changelog-github": "^1.0.1",
|
|
53
|
+
"@changesets/cli": "^3.0.3",
|
|
54
|
+
"@nestjs/common": "^11.0.0",
|
|
55
|
+
"@thunderid/eslint-plugin": "0.0.2",
|
|
56
|
+
"@thunderid/prettier-config": "0.0.2",
|
|
57
|
+
"@types/cookie-parser": "^1.4.8",
|
|
58
|
+
"@types/express": "^5.0.6",
|
|
59
|
+
"@types/node": "22.15.3",
|
|
60
|
+
"eslint": "9.39.4",
|
|
61
|
+
"prettier": "3.6.2",
|
|
62
|
+
"reflect-metadata": "^0.2.2",
|
|
63
|
+
"rimraf": "6.1.3",
|
|
64
|
+
"rolldown": "1.0.0-beta.45",
|
|
65
|
+
"rxjs": "^7.8.1",
|
|
66
|
+
"typescript": "5.9.3",
|
|
67
|
+
"vitest": "4.1.8"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@thunderid/express": "^0.2.5"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@nestjs/common": ">=10.0.0"
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=20.12"
|
|
80
|
+
}
|
|
81
|
+
}
|