cloud-ide-auth 1.0.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/README.md +217 -0
- package/esm2022/cloud-ide-auth.mjs +5 -0
- package/esm2022/lib/auth/forgot-password/forgot-password.component.mjs +62 -0
- package/esm2022/lib/auth/reset-password/reset-password.component.mjs +57 -0
- package/esm2022/lib/auth/sign-in/sign-in.component.mjs +78 -0
- package/esm2022/lib/cloud-ide-auth.component.mjs +16 -0
- package/esm2022/lib/cloud-ide-auth.routes.mjs +24 -0
- package/esm2022/lib/cloud-ide-auth.service.mjs +165 -0
- package/esm2022/public-api.mjs +8 -0
- package/fesm2022/cloud-ide-auth-reset-password.component-s7NMNjch.mjs +60 -0
- package/fesm2022/cloud-ide-auth-reset-password.component-s7NMNjch.mjs.map +1 -0
- package/fesm2022/cloud-ide-auth-sign-in.component-Cu4z1fIE.mjs +81 -0
- package/fesm2022/cloud-ide-auth-sign-in.component-Cu4z1fIE.mjs.map +1 -0
- package/fesm2022/cloud-ide-auth.mjs +281 -0
- package/fesm2022/cloud-ide-auth.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/auth/forgot-password/forgot-password.component.d.ts +16 -0
- package/lib/auth/reset-password/reset-password.component.d.ts +18 -0
- package/lib/auth/sign-in/sign-in.component.d.ts +26 -0
- package/lib/cloud-ide-auth.component.d.ts +5 -0
- package/lib/cloud-ide-auth.routes.d.ts +2 -0
- package/lib/cloud-ide-auth.service.d.ts +29 -0
- package/package.json +25 -0
- package/public-api.d.ts +4 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, Injectable, Component } from '@angular/core';
|
|
4
|
+
import { cidePath, hostManagerRoutesUrl, authRoutesUrl, MResetPassword, validateRequestModal, MForgotPassword } from 'cloud-ide-lms-model';
|
|
5
|
+
import { BehaviorSubject } from 'rxjs';
|
|
6
|
+
import { RouterOutlet, Router } from '@angular/router';
|
|
7
|
+
import * as i1 from '@angular/forms';
|
|
8
|
+
import { FormGroup, FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
+
import { CommonModule } from '@angular/common';
|
|
10
|
+
import { CideInputComponent, CideEleButtonComponent } from 'cloud-ide-element';
|
|
11
|
+
|
|
12
|
+
class CloudIdeAuthService {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.auth_user_mst = new BehaviorSubject({});
|
|
15
|
+
this._auth_token = "";
|
|
16
|
+
// Storage keys
|
|
17
|
+
this.TOKEN_STORAGE_KEY = 'cide_auth_token';
|
|
18
|
+
this.USER_STORAGE_KEY = 'cide_auth_user';
|
|
19
|
+
// Modern Angular v20 dependency injection pattern
|
|
20
|
+
this.http = inject(HttpClient);
|
|
21
|
+
// Modern Angular v20 pattern: Use constructor for initialization only
|
|
22
|
+
this.loadAuthDataFromStorage();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if localStorage is available (browser environment)
|
|
26
|
+
*/
|
|
27
|
+
isLocalStorageAvailable() {
|
|
28
|
+
try {
|
|
29
|
+
return typeof window !== 'undefined' && typeof localStorage !== 'undefined';
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Getter and setter for auth_token with localStorage persistence
|
|
36
|
+
get auth_token() {
|
|
37
|
+
return this._auth_token;
|
|
38
|
+
}
|
|
39
|
+
set auth_token(value) {
|
|
40
|
+
this._auth_token = value;
|
|
41
|
+
if (!this.isLocalStorageAvailable()) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (value) {
|
|
45
|
+
localStorage.setItem(this.TOKEN_STORAGE_KEY, value);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
localStorage.removeItem(this.TOKEN_STORAGE_KEY);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Load authentication data from localStorage on service initialization
|
|
52
|
+
loadAuthDataFromStorage() {
|
|
53
|
+
if (!this.isLocalStorageAvailable()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
// Load token
|
|
58
|
+
const storedToken = localStorage.getItem(this.TOKEN_STORAGE_KEY);
|
|
59
|
+
if (storedToken) {
|
|
60
|
+
this._auth_token = storedToken;
|
|
61
|
+
}
|
|
62
|
+
// Load user data
|
|
63
|
+
const storedUserData = localStorage.getItem(this.USER_STORAGE_KEY);
|
|
64
|
+
if (storedUserData) {
|
|
65
|
+
const userData = JSON.parse(storedUserData);
|
|
66
|
+
this.auth_user_mst.next(userData);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error('Error loading auth data from storage:', error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Store user data in localStorage
|
|
74
|
+
storeUserData(userData) {
|
|
75
|
+
if (userData) {
|
|
76
|
+
this.auth_user_mst.next(userData);
|
|
77
|
+
if (this.isLocalStorageAvailable()) {
|
|
78
|
+
localStorage.setItem(this.USER_STORAGE_KEY, JSON.stringify(userData));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
signIn(body) {
|
|
83
|
+
if (body?.user_password) {
|
|
84
|
+
if (body?.user_password?.length <= 6) {
|
|
85
|
+
body.custom_login_method = "mpin";
|
|
86
|
+
body.mpin_pin = body?.user_password;
|
|
87
|
+
body.user_password = "";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return this.http?.post(cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, authRoutesUrl?.module, authRoutesUrl?.signIn]), body);
|
|
91
|
+
}
|
|
92
|
+
forgotPassword(body) {
|
|
93
|
+
return this.http?.post(cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, authRoutesUrl?.module, authRoutesUrl?.forgotPassword]), body);
|
|
94
|
+
}
|
|
95
|
+
resetPassword(body) {
|
|
96
|
+
const payload = new MResetPassword(body);
|
|
97
|
+
if (payload?.Validate) {
|
|
98
|
+
payload?.Validate();
|
|
99
|
+
}
|
|
100
|
+
return this.http?.post(cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, authRoutesUrl?.module, authRoutesUrl?.resetPassword]), body);
|
|
101
|
+
}
|
|
102
|
+
// Sign out the user and clear all stored auth data
|
|
103
|
+
signOut() {
|
|
104
|
+
// Clear token and user data from memory
|
|
105
|
+
this._auth_token = "";
|
|
106
|
+
this.auth_user_mst.next({});
|
|
107
|
+
// Clear stored data
|
|
108
|
+
if (this.isLocalStorageAvailable()) {
|
|
109
|
+
localStorage.removeItem(this.TOKEN_STORAGE_KEY);
|
|
110
|
+
localStorage.removeItem(this.USER_STORAGE_KEY);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Check if user is authenticated
|
|
114
|
+
isAuthenticated() {
|
|
115
|
+
return !!this._auth_token;
|
|
116
|
+
}
|
|
117
|
+
// Get current user data
|
|
118
|
+
getCurrentUser() {
|
|
119
|
+
return this.auth_user_mst.getValue();
|
|
120
|
+
}
|
|
121
|
+
// Check if token is expired
|
|
122
|
+
isTokenExpired() {
|
|
123
|
+
try {
|
|
124
|
+
if (!this._auth_token) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
// Extract the payload from the JWT token
|
|
128
|
+
const tokenParts = this._auth_token.split('.');
|
|
129
|
+
if (tokenParts.length !== 3) {
|
|
130
|
+
return true; // Not a valid JWT token
|
|
131
|
+
}
|
|
132
|
+
const payload = JSON.parse(atob(tokenParts[1]));
|
|
133
|
+
// Check expiration time
|
|
134
|
+
const expiration = payload.exp * 1000; // Convert seconds to milliseconds
|
|
135
|
+
return Date.now() >= expiration;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error('Error checking token expiration:', error);
|
|
139
|
+
return true; // Assume expired if there's an error
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Refresh auth data if needed based on stored data
|
|
143
|
+
refreshAuthState() {
|
|
144
|
+
// If we have a token but no user data, try to load user data
|
|
145
|
+
if (this._auth_token && Object.keys(this.auth_user_mst.getValue()).length === 0 && this.isLocalStorageAvailable()) {
|
|
146
|
+
const storedUserData = localStorage.getItem(this.USER_STORAGE_KEY);
|
|
147
|
+
if (storedUserData) {
|
|
148
|
+
try {
|
|
149
|
+
const userData = JSON.parse(storedUserData);
|
|
150
|
+
this.auth_user_mst.next(userData);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
console.error('Error parsing stored user data:', error);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// If token is expired, sign out
|
|
158
|
+
if (this.isTokenExpired()) {
|
|
159
|
+
this.signOut();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: CloudIdeAuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
163
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: CloudIdeAuthService, providedIn: 'root' }); }
|
|
164
|
+
}
|
|
165
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: CloudIdeAuthService, decorators: [{
|
|
166
|
+
type: Injectable,
|
|
167
|
+
args: [{
|
|
168
|
+
providedIn: 'root'
|
|
169
|
+
}]
|
|
170
|
+
}], ctorParameters: () => [] });
|
|
171
|
+
|
|
172
|
+
class CloudIdeAuthComponent {
|
|
173
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: CloudIdeAuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
174
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.7", type: CloudIdeAuthComponent, isStandalone: true, selector: "cide-auth-wrapper", ngImport: i0, template: `
|
|
175
|
+
<router-outlet></router-outlet>
|
|
176
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
|
|
177
|
+
}
|
|
178
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: CloudIdeAuthComponent, decorators: [{
|
|
179
|
+
type: Component,
|
|
180
|
+
args: [{ selector: 'cide-auth-wrapper', standalone: true, imports: [RouterOutlet], template: `
|
|
181
|
+
<router-outlet></router-outlet>
|
|
182
|
+
` }]
|
|
183
|
+
}] });
|
|
184
|
+
|
|
185
|
+
var cloudIdeAuth_component = /*#__PURE__*/Object.freeze({
|
|
186
|
+
__proto__: null,
|
|
187
|
+
CloudIdeAuthComponent: CloudIdeAuthComponent
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
class CideAuthForgotPasswordComponent {
|
|
191
|
+
constructor() {
|
|
192
|
+
this.setup_param = { form_loading: false };
|
|
193
|
+
this.erro_message = "";
|
|
194
|
+
this.authService = inject(CloudIdeAuthService);
|
|
195
|
+
this.route = inject(Router);
|
|
196
|
+
this.forgotPassswordForm = new FormGroup({
|
|
197
|
+
custom_forgot_password_method: new FormControl('username'),
|
|
198
|
+
user_username: new FormControl(''),
|
|
199
|
+
user_emailid: new FormControl(''),
|
|
200
|
+
user_mobileno: new FormControl(),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
onForgotPasssword() {
|
|
204
|
+
if (this.forgotPassswordForm.valid) {
|
|
205
|
+
this.setup_param.form_loading = true;
|
|
206
|
+
const validate = validateRequestModal(new MForgotPassword(this.forgotPassswordForm?.value));
|
|
207
|
+
console.log(validate);
|
|
208
|
+
if (validate === true) {
|
|
209
|
+
this.authService.forgotPassword(this.forgotPassswordForm?.value)?.subscribe({
|
|
210
|
+
next: (response) => {
|
|
211
|
+
if (response?.success === true) {
|
|
212
|
+
this.setup_param.form_loading = false;
|
|
213
|
+
this.route.navigate(['auth', 'sign-in']);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
error: (error) => {
|
|
217
|
+
this.setup_param.form_loading = false;
|
|
218
|
+
this.erro_message = error?.error?.message;
|
|
219
|
+
console.log(error);
|
|
220
|
+
setTimeout(() => {
|
|
221
|
+
this.erro_message = "";
|
|
222
|
+
}, 3000);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
this.setup_param.form_loading = false;
|
|
228
|
+
this.erro_message = validate.first;
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
this.erro_message = "";
|
|
231
|
+
}, 3000);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: CideAuthForgotPasswordComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
236
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.7", type: CideAuthForgotPasswordComponent, isStandalone: true, selector: "cide-auth-forgot-password", ngImport: i0, template: "<!-- https://play.tailwindcss.com/lfO85drpUy -->\n<!-- Main Div Outer Div-->\n<div class=\"cide-font-poppins tw-flex tw-min-h-screen tw-w-full tw-bg-gray-50 tw-py-3\">\n <!-- Forrm Wrapper -->\n <div class=\"tw-m-auto tw-w-96 tw-rounded-2xl tw-bg-white tw-py-6 tw-shadow-xl\">\n <!-- Logo Wrapper -->\n <div class=\"tw-m-auto tw-h-32 tw-w-64 tw-text-center\">\n <img src=\"https://console.cloudidesys.com/assets/Cloud%20IDE%20Logo%20Dark.png\" class=\"tw-m-auto tw-h-full\"\n alt=\"Cloud IDE Logo\" />\n </div> <!-- Entity name here -->\n <div class=\"tw-my-2 tw-text-center tw-text-xl tw-font-semibold\">Forgot Password</div>\n <!-- Error Logger -->\n <div class=\"tw-w-full tw-select-none tw-py-1 tw-text-center tw-text-red-500 tw-h-4 tw-text-sm\">{{erro_message}}</div>\n \n <!-- section for controls -->\n <form [formGroup]=\"forgotPassswordForm\" (ngSubmit)=\"onForgotPasssword()\" novalidate>\n <div class=\"tw-m-auto tw-pb-3 tw-pt-3\">\n <!-- Username -->\n <div class=\"tw-m-auto tw-w-80\">\n <cide-ele-input id=\"user_username\" formControlName=\"user_username\"></cide-ele-input>\n </div> <!-- Forgot Password button -->\n <div class=\"tw-w-80 tw-m-auto tw-mt-3\">\n <button cideEleButton id=\"reset_password_link_button\" [loading]=\"setup_param.form_loading\" [disabled]=\"!forgotPassswordForm.valid\">Reset Password</button>\n </div>\n </div>\n </form>\n </div>\n </div>", styles: [""], dependencies: [{ kind: "component", type: CideInputComponent, selector: "cide-ele-input", inputs: ["fill", "label", "labelHide", "disabled", "clearInput", "labelPlacement", "labelDir", "placeholder", "leadingIcon", "trailingIcon", "helperText", "helperTextCollapse", "hideHelperAndErrorText", "errorText", "maxlength", "minlength", "required", "autocapitalize", "autocomplete", "type", "width", "id", "ngModel", "option", "min", "max", "size"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: CommonModule }, { kind: "component", type: CideEleButtonComponent, selector: "button[cideEleButton], a[cideEleButton]", inputs: ["label", "variant", "size", "type", "shape", "elevation", "disabled", "id", "loading", "fullWidth", "leftIcon", "rightIcon", "customClass", "tooltip", "ariaLabel", "testId", "routerLink", "routerExtras", "preventDoubleClick", "animated"], outputs: ["btnClick", "doubleClick"] }] }); }
|
|
237
|
+
}
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: CideAuthForgotPasswordComponent, decorators: [{
|
|
239
|
+
type: Component,
|
|
240
|
+
args: [{ selector: 'cide-auth-forgot-password', standalone: true, imports: [CideInputComponent, ReactiveFormsModule, CommonModule, CideEleButtonComponent], template: "<!-- https://play.tailwindcss.com/lfO85drpUy -->\n<!-- Main Div Outer Div-->\n<div class=\"cide-font-poppins tw-flex tw-min-h-screen tw-w-full tw-bg-gray-50 tw-py-3\">\n <!-- Forrm Wrapper -->\n <div class=\"tw-m-auto tw-w-96 tw-rounded-2xl tw-bg-white tw-py-6 tw-shadow-xl\">\n <!-- Logo Wrapper -->\n <div class=\"tw-m-auto tw-h-32 tw-w-64 tw-text-center\">\n <img src=\"https://console.cloudidesys.com/assets/Cloud%20IDE%20Logo%20Dark.png\" class=\"tw-m-auto tw-h-full\"\n alt=\"Cloud IDE Logo\" />\n </div> <!-- Entity name here -->\n <div class=\"tw-my-2 tw-text-center tw-text-xl tw-font-semibold\">Forgot Password</div>\n <!-- Error Logger -->\n <div class=\"tw-w-full tw-select-none tw-py-1 tw-text-center tw-text-red-500 tw-h-4 tw-text-sm\">{{erro_message}}</div>\n \n <!-- section for controls -->\n <form [formGroup]=\"forgotPassswordForm\" (ngSubmit)=\"onForgotPasssword()\" novalidate>\n <div class=\"tw-m-auto tw-pb-3 tw-pt-3\">\n <!-- Username -->\n <div class=\"tw-m-auto tw-w-80\">\n <cide-ele-input id=\"user_username\" formControlName=\"user_username\"></cide-ele-input>\n </div> <!-- Forgot Password button -->\n <div class=\"tw-w-80 tw-m-auto tw-mt-3\">\n <button cideEleButton id=\"reset_password_link_button\" [loading]=\"setup_param.form_loading\" [disabled]=\"!forgotPassswordForm.valid\">Reset Password</button>\n </div>\n </div>\n </form>\n </div>\n </div>" }]
|
|
241
|
+
}], ctorParameters: () => [] });
|
|
242
|
+
|
|
243
|
+
var forgotPassword_component = /*#__PURE__*/Object.freeze({
|
|
244
|
+
__proto__: null,
|
|
245
|
+
CideAuthForgotPasswordComponent: CideAuthForgotPasswordComponent
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const authRoutes = {
|
|
249
|
+
path: "auth",
|
|
250
|
+
loadComponent: () => Promise.resolve().then(function () { return cloudIdeAuth_component; }).then(c => c.CloudIdeAuthComponent),
|
|
251
|
+
children: [
|
|
252
|
+
{
|
|
253
|
+
path: "",
|
|
254
|
+
pathMatch: 'full',
|
|
255
|
+
redirectTo: 'sign-in'
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
path: "sign-in",
|
|
259
|
+
loadComponent: () => import('./cloud-ide-auth-sign-in.component-Cu4z1fIE.mjs').then(c => c.CideAuthSignInComponent)
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
path: "forgot-password",
|
|
263
|
+
loadComponent: () => Promise.resolve().then(function () { return forgotPassword_component; }).then(c => c.CideAuthForgotPasswordComponent)
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
path: "reset-password/:rout_token",
|
|
267
|
+
loadComponent: () => import('./cloud-ide-auth-reset-password.component-s7NMNjch.mjs').then(c => c.CideAuthResetPasswordComponent)
|
|
268
|
+
}
|
|
269
|
+
]
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/*
|
|
273
|
+
* Public API Surface of cloud-ide-auth
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Generated bundle index. Do not edit.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
export { CideAuthForgotPasswordComponent, CloudIdeAuthComponent, CloudIdeAuthService, authRoutes };
|
|
281
|
+
//# sourceMappingURL=cloud-ide-auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-ide-auth.mjs","sources":["../../../projects/cloud-ide-auth/src/lib/cloud-ide-auth.service.ts","../../../projects/cloud-ide-auth/src/lib/cloud-ide-auth.component.ts","../../../projects/cloud-ide-auth/src/lib/auth/forgot-password/forgot-password.component.ts","../../../projects/cloud-ide-auth/src/lib/auth/forgot-password/forgot-password.component.html","../../../projects/cloud-ide-auth/src/lib/cloud-ide-auth.routes.ts","../../../projects/cloud-ide-auth/src/public-api.ts","../../../projects/cloud-ide-auth/src/cloud-ide-auth.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\nimport { Injectable, inject } from '@angular/core';\nimport { authRoutesUrl, cidePath, hostManagerRoutesUrl, IUser, loginControllerResponse, MLogin, MForgotPassword, ForgotPasswordControllerResponse, MResetPassword, ResetPasswordControllerResponse } from 'cloud-ide-lms-model';\nimport { BehaviorSubject, Observable } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class CloudIdeAuthService {\n public auth_user_mst: BehaviorSubject<IUser> = new BehaviorSubject({});\n private _auth_token: string = \"\";\n \n // Storage keys\n private readonly TOKEN_STORAGE_KEY = 'cide_auth_token';\n private readonly USER_STORAGE_KEY = 'cide_auth_user';\n\n // Modern Angular v20 dependency injection pattern\n private http = inject(HttpClient);\n\n constructor() {\n // Modern Angular v20 pattern: Use constructor for initialization only\n this.loadAuthDataFromStorage();\n }\n\n /**\n * Check if localStorage is available (browser environment)\n */\n private isLocalStorageAvailable(): boolean {\n try {\n return typeof window !== 'undefined' && typeof localStorage !== 'undefined';\n } catch {\n return false;\n }\n }\n\n // Getter and setter for auth_token with localStorage persistence\n get auth_token(): string {\n return this._auth_token;\n }\n \n set auth_token(value: string) {\n this._auth_token = value;\n if (!this.isLocalStorageAvailable()) {\n return;\n }\n if (value) {\n localStorage.setItem(this.TOKEN_STORAGE_KEY, value);\n } else {\n localStorage.removeItem(this.TOKEN_STORAGE_KEY);\n }\n }\n\n // Load authentication data from localStorage on service initialization\n private loadAuthDataFromStorage(): void {\n if (!this.isLocalStorageAvailable()) {\n return;\n }\n \n try {\n // Load token\n const storedToken = localStorage.getItem(this.TOKEN_STORAGE_KEY);\n if (storedToken) {\n this._auth_token = storedToken;\n }\n \n // Load user data\n const storedUserData = localStorage.getItem(this.USER_STORAGE_KEY);\n if (storedUserData) {\n const userData = JSON.parse(storedUserData);\n this.auth_user_mst.next(userData);\n }\n } catch (error) {\n console.error('Error loading auth data from storage:', error);\n }\n }\n\n // Store user data in localStorage\n public storeUserData(userData: IUser): void {\n if (userData) {\n this.auth_user_mst.next(userData);\n if (this.isLocalStorageAvailable()) {\n localStorage.setItem(this.USER_STORAGE_KEY, JSON.stringify(userData));\n }\n }\n }\n\n signIn(body: MLogin): Observable<loginControllerResponse> {\n if (body?.user_password) {\n if (body?.user_password?.length <= 6) {\n body.custom_login_method = \"mpin\";\n body.mpin_pin = body?.user_password;\n body.user_password = \"\";\n }\n }\n return this.http?.post(cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, authRoutesUrl?.module, authRoutesUrl?.signIn]), body);\n }\n\n forgotPassword(body: MForgotPassword): Observable<ForgotPasswordControllerResponse> {\n return this.http?.post(cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, authRoutesUrl?.module, authRoutesUrl?.forgotPassword]), body);\n }\n\n resetPassword(body: MResetPassword): Observable<ResetPasswordControllerResponse> {\n const payload = new MResetPassword(body);\n if (payload?.Validate) {\n payload?.Validate();\n }\n return this.http?.post(cidePath?.join([hostManagerRoutesUrl?.cideSuiteHost, authRoutesUrl?.module, authRoutesUrl?.resetPassword]), body);\n }\n \n // Sign out the user and clear all stored auth data\n signOut(): void {\n // Clear token and user data from memory\n this._auth_token = \"\";\n this.auth_user_mst.next({});\n \n // Clear stored data\n if (this.isLocalStorageAvailable()) {\n localStorage.removeItem(this.TOKEN_STORAGE_KEY);\n localStorage.removeItem(this.USER_STORAGE_KEY);\n }\n }\n \n // Check if user is authenticated\n isAuthenticated(): boolean {\n return !!this._auth_token;\n }\n\n // Get current user data \n getCurrentUser(): IUser {\n return this.auth_user_mst.getValue();\n }\n \n // Check if token is expired\n isTokenExpired(): boolean {\n try {\n if (!this._auth_token) {\n return true;\n }\n \n // Extract the payload from the JWT token\n const tokenParts = this._auth_token.split('.');\n if (tokenParts.length !== 3) {\n return true; // Not a valid JWT token\n }\n \n const payload = JSON.parse(atob(tokenParts[1]));\n \n // Check expiration time\n const expiration = payload.exp * 1000; // Convert seconds to milliseconds\n return Date.now() >= expiration;\n } catch (error) {\n console.error('Error checking token expiration:', error);\n return true; // Assume expired if there's an error\n }\n }\n \n // Refresh auth data if needed based on stored data\n refreshAuthState(): void {\n // If we have a token but no user data, try to load user data\n if (this._auth_token && Object.keys(this.auth_user_mst.getValue()).length === 0 && this.isLocalStorageAvailable()) {\n const storedUserData = localStorage.getItem(this.USER_STORAGE_KEY);\n if (storedUserData) {\n try {\n const userData = JSON.parse(storedUserData);\n this.auth_user_mst.next(userData);\n } catch (error) {\n console.error('Error parsing stored user data:', error);\n }\n }\n }\n \n // If token is expired, sign out\n if (this.isTokenExpired()) {\n this.signOut();\n }\n }\n}\n","import { Component } from '@angular/core';\r\nimport { RouterOutlet } from '@angular/router';\r\n\r\n@Component({\r\n selector: 'cide-auth-wrapper',\r\n standalone: true,\r\n imports: [RouterOutlet],\r\n template: `\r\n <router-outlet></router-outlet>\r\n `,\r\n styles: ``\r\n})\r\nexport class CloudIdeAuthComponent {\r\n\r\n}\r\n","import { Component, inject } from '@angular/core';\nimport { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';\nimport { CommonModule } from '@angular/common';\nimport { Router } from '@angular/router';\nimport { FormGroupModel } from '../sign-in/sign-in.component';\nimport { forgotPasswordMethod, MForgotPassword, validateRequestModal } from 'cloud-ide-lms-model';\nimport { CloudIdeAuthService } from '../../cloud-ide-auth.service';\nimport { CideEleButtonComponent, CideInputComponent } from 'cloud-ide-element';\n\n@Component({\n selector: 'cide-auth-forgot-password',\n standalone: true,\n imports: [CideInputComponent, ReactiveFormsModule, CommonModule, CideEleButtonComponent],\n templateUrl: './forgot-password.component.html',\n styleUrl: './forgot-password.component.css'\n})\nexport class CideAuthForgotPasswordComponent {\n public setup_param = { form_loading: false };\n public forgotPassswordForm: FormGroupModel<MForgotPassword>;\n public erro_message = \"\";\n\n private authService = inject(CloudIdeAuthService);\n private route = inject(Router);\n\n constructor() {\n\n this.forgotPassswordForm = new FormGroup({\n custom_forgot_password_method: new FormControl<forgotPasswordMethod>('username'),\n user_username: new FormControl(''),\n user_emailid: new FormControl(''),\n user_mobileno: new FormControl(),\n }) as unknown as FormGroupModel<MForgotPassword>;\n }\n\n onForgotPasssword() {\n if (this.forgotPassswordForm.valid) {\n this.setup_param.form_loading = true;\n const validate = validateRequestModal(new MForgotPassword(this.forgotPassswordForm?.value as MForgotPassword));\n console.log(validate)\n if(validate === true){\n this.authService.forgotPassword(this.forgotPassswordForm?.value as MForgotPassword)?.subscribe({\n next: (response) => {\n if (response?.success === true) {\n this.setup_param.form_loading = false;\n this.route.navigate(['auth', 'sign-in'])\n }\n },\n error: (error) => {\n this.setup_param.form_loading = false;\n this.erro_message = error?.error?.message;\n console.log(error)\n setTimeout(() => {\n this.erro_message = \"\"\n }, 3000)\n }\n });\n } else {\n this.setup_param.form_loading = false;\n this.erro_message = validate.first;\n setTimeout(() => {\n this.erro_message = \"\"\n }, 3000)\n }\n }\n }\n}","<!-- https://play.tailwindcss.com/lfO85drpUy -->\n<!-- Main Div Outer Div-->\n<div class=\"cide-font-poppins tw-flex tw-min-h-screen tw-w-full tw-bg-gray-50 tw-py-3\">\n <!-- Forrm Wrapper -->\n <div class=\"tw-m-auto tw-w-96 tw-rounded-2xl tw-bg-white tw-py-6 tw-shadow-xl\">\n <!-- Logo Wrapper -->\n <div class=\"tw-m-auto tw-h-32 tw-w-64 tw-text-center\">\n <img src=\"https://console.cloudidesys.com/assets/Cloud%20IDE%20Logo%20Dark.png\" class=\"tw-m-auto tw-h-full\"\n alt=\"Cloud IDE Logo\" />\n </div> <!-- Entity name here -->\n <div class=\"tw-my-2 tw-text-center tw-text-xl tw-font-semibold\">Forgot Password</div>\n <!-- Error Logger -->\n <div class=\"tw-w-full tw-select-none tw-py-1 tw-text-center tw-text-red-500 tw-h-4 tw-text-sm\">{{erro_message}}</div>\n \n <!-- section for controls -->\n <form [formGroup]=\"forgotPassswordForm\" (ngSubmit)=\"onForgotPasssword()\" novalidate>\n <div class=\"tw-m-auto tw-pb-3 tw-pt-3\">\n <!-- Username -->\n <div class=\"tw-m-auto tw-w-80\">\n <cide-ele-input id=\"user_username\" formControlName=\"user_username\"></cide-ele-input>\n </div> <!-- Forgot Password button -->\n <div class=\"tw-w-80 tw-m-auto tw-mt-3\">\n <button cideEleButton id=\"reset_password_link_button\" [loading]=\"setup_param.form_loading\" [disabled]=\"!forgotPassswordForm.valid\">Reset Password</button>\n </div>\n </div>\n </form>\n </div>\n </div>","import { Route } from '@angular/router';\r\n\r\nexport const authRoutes: Route =\r\n{\r\n path: \"auth\",\r\n loadComponent: () => import('./cloud-ide-auth.component').then(c => c.CloudIdeAuthComponent),\r\n children: [\r\n {\r\n path: \"\",\r\n pathMatch: 'full',\r\n redirectTo: 'sign-in'\r\n },\r\n {\r\n path: \"sign-in\",\r\n loadComponent: () => import('./auth/sign-in/sign-in.component').then(c => c.CideAuthSignInComponent)\r\n },\r\n {\r\n path: \"forgot-password\",\r\n loadComponent: () => import('./auth/forgot-password/forgot-password.component').then(c => c.CideAuthForgotPasswordComponent)\r\n },\r\n {\r\n path: \"reset-password/:rout_token\",\r\n loadComponent: () => import('./auth/reset-password/reset-password.component').then(c => c.CideAuthResetPasswordComponent)\r\n }\r\n ]\r\n}\r\n","/*\r\n * Public API Surface of cloud-ide-auth\r\n */\r\n\r\nexport * from './lib/cloud-ide-auth.service';\r\nexport * from './lib/cloud-ide-auth.component';\r\nexport * from './lib/auth/forgot-password/forgot-password.component';\r\nexport * from './lib/cloud-ide-auth.routes';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;MAQa,mBAAmB,CAAA;AAW9B,IAAA,WAAA,GAAA;AAVO,QAAA,IAAA,CAAA,aAAa,GAA2B,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAW,CAAA,WAAA,GAAW,EAAE,CAAC;;QAGhB,IAAiB,CAAA,iBAAA,GAAG,iBAAiB,CAAC;QACtC,IAAgB,CAAA,gBAAA,GAAG,gBAAgB,CAAC;;AAG7C,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;;QAIhC,IAAI,CAAC,uBAAuB,EAAE,CAAC;KAChC;AAED;;AAEG;IACK,uBAAuB,GAAA;AAC7B,QAAA,IAAI;YACF,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,YAAY,KAAK,WAAW,CAAC;SAC7E;AAAC,QAAA,MAAM;AACN,YAAA,OAAO,KAAK,CAAC;SACd;KACF;;AAGD,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;KACzB;IAED,IAAI,UAAU,CAAC,KAAa,EAAA;AAC1B,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;AACzB,QAAA,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE;YACnC,OAAO;SACR;QACD,IAAI,KAAK,EAAE;YACT,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;SACrD;aAAM;AACL,YAAA,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;SACjD;KACF;;IAGO,uBAAuB,GAAA;AAC7B,QAAA,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE;YACnC,OAAO;SACR;AAED,Q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A,CAAA,EAAA;;2FAI5E,+BAA+B,EAAA,UAAA,EAAA,CAAA;kBAP3C,SAAS;+BACE,2BAA2B,EAAA,UAAA,EACzB,IAAI,EAAA,OAAA,EACP,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,YAAY,EAAE,sBAAsB,CAAC,EAAA,QAAA,EAAA,mhDAAA,EAAA,CAAA;;;;;;;;AEV7E,MAAA,UAAU,GACvB;AACI,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,aAAa,EAAE,MAAM,sEAAoC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC;AAC5F,IAAA,QAAQ,EAAE;AACN,QAAA;AACI,YAAA,IAAI,EAAE,EAAE;AACR,YAAA,SAAS,EAAE,MAAM;AACjB,YAAA,UAAU,EAAE,SAAS;AACxB,SAAA;AACD,QAAA;AACI,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,aAAa,EAAE,MAAM,OAAO,iDAAkC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,uBAAuB,CAAC;AACvG,SAAA;AACD,QAAA;AACI,YAAA,IAAI,EAAE,iBAAiB;AACvB,YAAA,aAAa,EAAE,MAAM,wEAA0D,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,+BAA+B,CAAC;AAC/H,SAAA;AACD,QAAA;AACI,YAAA,IAAI,EAAE,4BAA4B;AAClC,YAAA,aAAa,EAAE,MAAM,OAAO,wDAAgD,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,8BAA8B,CAAC;AAC5H,SAAA;AACJ,KAAA;;;ACxBL;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormGroupModel } from '../sign-in/sign-in.component';
|
|
2
|
+
import { MForgotPassword } from 'cloud-ide-lms-model';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class CideAuthForgotPasswordComponent {
|
|
5
|
+
setup_param: {
|
|
6
|
+
form_loading: boolean;
|
|
7
|
+
};
|
|
8
|
+
forgotPassswordForm: FormGroupModel<MForgotPassword>;
|
|
9
|
+
erro_message: string;
|
|
10
|
+
private authService;
|
|
11
|
+
private route;
|
|
12
|
+
constructor();
|
|
13
|
+
onForgotPasssword(): void;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CideAuthForgotPasswordComponent, never>;
|
|
15
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CideAuthForgotPasswordComponent, "cide-auth-forgot-password", never, {}, {}, never, never, true, never>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormGroupModel } from '../sign-in/sign-in.component';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class CideAuthResetPasswordComponent {
|
|
4
|
+
setup_param: {
|
|
5
|
+
form_loading: boolean;
|
|
6
|
+
};
|
|
7
|
+
resetPassswordForm: FormGroupModel<{
|
|
8
|
+
user_new_password: string;
|
|
9
|
+
user_confirm_password: string;
|
|
10
|
+
}>;
|
|
11
|
+
erro_message: string;
|
|
12
|
+
private authService;
|
|
13
|
+
private route;
|
|
14
|
+
constructor();
|
|
15
|
+
onForgotPasssword(): void;
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CideAuthResetPasswordComponent, never>;
|
|
17
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CideAuthResetPasswordComponent, "cide-auth-reset-password", never, {}, {}, never, never, true, never>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { FormControl, FormGroup } from '@angular/forms';
|
|
3
|
+
import { MLogin } from 'cloud-ide-lms-model';
|
|
4
|
+
import { CideLytSharedWrapperComponent, CideLytSharedWrapperSetupParam } from 'cloud-ide-layout';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export type FormGroupModel<T> = FormGroup<{
|
|
7
|
+
[K in keyof T]: FormControl<T[K]>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class CideAuthSignInComponent extends CideLytSharedWrapperComponent implements OnInit {
|
|
10
|
+
shared_wrapper_setup_param: Partial<CideLytSharedWrapperSetupParam>;
|
|
11
|
+
setup_param: {
|
|
12
|
+
form_loading: boolean;
|
|
13
|
+
};
|
|
14
|
+
loginForm: FormGroupModel<MLogin>;
|
|
15
|
+
erro_message: string;
|
|
16
|
+
private returnUrl;
|
|
17
|
+
private router;
|
|
18
|
+
private activatedRoute;
|
|
19
|
+
private authService;
|
|
20
|
+
private appStateService;
|
|
21
|
+
constructor();
|
|
22
|
+
ngOnInit(): void;
|
|
23
|
+
onSignIn(): void;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CideAuthSignInComponent, never>;
|
|
25
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CideAuthSignInComponent, "cide-auth-sign-in", never, {}, {}, never, never, true, never>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export declare class CloudIdeAuthComponent {
|
|
3
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CloudIdeAuthComponent, never>;
|
|
4
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CloudIdeAuthComponent, "cide-auth-wrapper", never, {}, {}, never, never, true, never>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IUser, loginControllerResponse, MLogin, MForgotPassword, ForgotPasswordControllerResponse, MResetPassword, ResetPasswordControllerResponse } from 'cloud-ide-lms-model';
|
|
2
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class CloudIdeAuthService {
|
|
5
|
+
auth_user_mst: BehaviorSubject<IUser>;
|
|
6
|
+
private _auth_token;
|
|
7
|
+
private readonly TOKEN_STORAGE_KEY;
|
|
8
|
+
private readonly USER_STORAGE_KEY;
|
|
9
|
+
private http;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Check if localStorage is available (browser environment)
|
|
13
|
+
*/
|
|
14
|
+
private isLocalStorageAvailable;
|
|
15
|
+
get auth_token(): string;
|
|
16
|
+
set auth_token(value: string);
|
|
17
|
+
private loadAuthDataFromStorage;
|
|
18
|
+
storeUserData(userData: IUser): void;
|
|
19
|
+
signIn(body: MLogin): Observable<loginControllerResponse>;
|
|
20
|
+
forgotPassword(body: MForgotPassword): Observable<ForgotPasswordControllerResponse>;
|
|
21
|
+
resetPassword(body: MResetPassword): Observable<ResetPasswordControllerResponse>;
|
|
22
|
+
signOut(): void;
|
|
23
|
+
isAuthenticated(): boolean;
|
|
24
|
+
getCurrentUser(): IUser;
|
|
25
|
+
isTokenExpired(): boolean;
|
|
26
|
+
refreshAuthState(): void;
|
|
27
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CloudIdeAuthService, never>;
|
|
28
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<CloudIdeAuthService>;
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cloud-ide-auth",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^18.0.0",
|
|
6
|
+
"@angular/core": "^18.0.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/cloud-ide-auth.mjs",
|
|
13
|
+
"typings": "index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"esm2022": "./esm2022/cloud-ide-auth.mjs",
|
|
21
|
+
"esm": "./esm2022/cloud-ide-auth.mjs",
|
|
22
|
+
"default": "./fesm2022/cloud-ide-auth.mjs"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/public-api.d.ts
ADDED