@asgardeo/node 0.0.1 → 0.0.2

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 CHANGED
@@ -28,7 +28,7 @@ import { AsgardeoNodeClient } from "@asgardeo/node";
28
28
 
29
29
  // Initialize the client
30
30
  const authClient = new AsgardeoNodeClient({
31
- clientID: "<your_client_id>",
31
+ clientId: "<your_client_id>",
32
32
  clientSecret: "<your_client_secret>",
33
33
  baseUrl: "https://api.asgardeo.io/t/<org_name>",
34
34
  callbackURL: "http://localhost:3000/callback"
@@ -40,7 +40,7 @@ const app = express();
40
40
 
41
41
  // Login endpoint
42
42
  app.get("/login", (req, res) => {
43
- const authUrl = authClient.getAuthorizationURL();
43
+ const authUrl = authClient.getSignInUrl();
44
44
  res.redirect(authUrl);
45
45
  });
46
46
 
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AuthClientConfig, BasicUserInfo, CustomGrantConfig, DataLayer, IdTokenPayload, FetchResponse, OIDCEndpoints, Store, TokenResponse } from '@asgardeo/javascript';
18
+ import { AuthClientConfig, TokenExchangeRequestConfig, StorageManager, IdTokenPayload, OIDCEndpoints, Storage, TokenResponse, User } from '@asgardeo/javascript';
19
19
  import { AuthURLCallback } from './models';
20
20
  /**
21
21
  * This class provides the necessary methods needed to implement authentication.
@@ -29,15 +29,15 @@ export declare class AsgardeoNodeClient<T> {
29
29
  * This is the constructor method that returns an instance of the `AsgardeoNodeClient` class.
30
30
  *
31
31
  * @param {AuthClientConfig<T>} config - The configuration object.
32
- * @param {Store} store - The store object.
32
+ * @param {Storage} store - The store object.
33
33
  *
34
34
  * @example
35
35
  * ```
36
- * const _store: Store = new DataStore();
36
+ * const _store: Storage = new DataStore();
37
37
  * const _config = {
38
- signInRedirectURL: "http://localhost:3000/sign-in",
39
- signOutRedirectURL: "http://localhost:3000/dashboard",
40
- clientID: "client ID",
38
+ afterSignInUrl: "http://localhost:3000/sign-in",
39
+ afterSignOutUrl: "http://localhost:3000/dashboard",
40
+ clientId: "client ID",
41
41
  serverOrigin: "https://api.asgardeo.io/t/<org_name>"
42
42
  };
43
43
  * const auth = new AsgardeoNodeClient(_config,_store);
@@ -47,13 +47,13 @@ export declare class AsgardeoNodeClient<T> {
47
47
  * @preserve
48
48
  */
49
49
  constructor();
50
- initialize(config: AuthClientConfig<T>, store?: Store): Promise<boolean>;
50
+ initialize(config: AuthClientConfig<T>, store?: Storage): Promise<boolean>;
51
51
  /**
52
52
  * This method logs in a user. If the authorization code is not available it will resolve with the
53
53
  * authorization URL to authorize the user.
54
54
  * @param {string} authorizationCode - The authorization code obtained from Asgardeo after a user signs in.
55
55
  * @param {String} sessionState - The session state obtained from Asgardeo after a user signs in.
56
- * @param {string} userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
56
+ * @param {string} userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
57
57
  * scenarios where each user should be uniquely identified.
58
58
  * @param {string} state - The state parameter in the redirect URL.
59
59
  *
@@ -108,15 +108,15 @@ export declare class AsgardeoNodeClient<T> {
108
108
  *
109
109
  * @example
110
110
  * ```
111
- * const isAuth = await authClient.isAuthenticated("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
111
+ * const isAuth = await authClient.isSignedIn("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
112
112
  * ```
113
113
  *
114
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isAuthenticated
114
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isSignedIn
115
115
  *
116
116
  * @memberof AsgardeoNodeClient
117
117
  *
118
118
  */
119
- isAuthenticated(userId: string): Promise<boolean>;
119
+ isSignedIn(userId: string): Promise<boolean>;
120
120
  /**
121
121
  * This method returns the id token.
122
122
  * @param {string} userId - The userId of the user.
@@ -126,15 +126,15 @@ export declare class AsgardeoNodeClient<T> {
126
126
  *
127
127
  * @example
128
128
  * ```
129
- * const isAuth = await authClient.getIDToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
129
+ * const isAuth = await authClient.getIdToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
130
130
  * ```
131
131
  *
132
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIDToken
132
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIdToken
133
133
  *
134
134
  * @memberof AsgardeoNodeClient
135
135
  *
136
136
  */
137
- getIDToken(userId: string): Promise<string>;
137
+ getIdToken(userId: string): Promise<string>;
138
138
  /**
139
139
  * This method returns an object containing basic user information obtained from the id token.
140
140
  * @param {string} userId - The userId of the user.
@@ -145,15 +145,15 @@ export declare class AsgardeoNodeClient<T> {
145
145
  *
146
146
  * @example
147
147
  * ```
148
- * const basicInfo = await authClient.getBasicUserInfo("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
148
+ * const basicInfo = await authClient.getUser("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
149
149
  * ```
150
150
  *
151
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getBasicUserInfo
151
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getUser
152
152
  *
153
153
  * @memberof AsgardeoNodeClient
154
154
  *
155
155
  */
156
- getBasicUserInfo(userId: string): Promise<BasicUserInfo>;
156
+ getUser(userId: string): Promise<User>;
157
157
  /**
158
158
  * This method returns an object containing the OIDC service endpoints returned by the `.well-known` endpoint.
159
159
  * @return {Promise<OIDCEndpoints>} -A Promise that resolves with
@@ -161,15 +161,15 @@ export declare class AsgardeoNodeClient<T> {
161
161
  *
162
162
  * @example
163
163
  * ```
164
- * const oidcEndpoints = await auth.getOIDCServiceEndpoints();
164
+ * const oidcEndpoints = await auth.getOpenIDProviderEndpoints();
165
165
  * ```
166
166
  *
167
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOIDCServiceEndpoints
167
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOpenIDProviderEndpoints
168
168
  *
169
169
  * @memberof AsgardeoNodeClient
170
170
  *
171
171
  */
172
- getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
172
+ getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
173
173
  /**
174
174
  * This method returns the decoded ID token payload.
175
175
  * @param {string} userId - The userId of the user.
@@ -180,15 +180,15 @@ export declare class AsgardeoNodeClient<T> {
180
180
  *
181
181
  * @example
182
182
  * ```
183
- * const decodedIDTokenPayload = await auth.getDecodedIDToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
183
+ * const decodedIDTokenPayload = await auth.getDecodedIdToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
184
184
  * ```
185
185
  *
186
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIDToken
186
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIdToken
187
187
  *
188
188
  * @memberof AsgardeoNodeClient
189
189
  *
190
190
  */
191
- getDecodedIDToken(userId?: string): Promise<IdTokenPayload>;
191
+ getDecodedIdToken(userId?: string): Promise<IdTokenPayload>;
192
192
  /**
193
193
  * This method returns the access token.
194
194
  * @param {string} userId - The userId of the user.
@@ -211,13 +211,13 @@ export declare class AsgardeoNodeClient<T> {
211
211
  /**
212
212
  * This method returns Promise that resolves with the token information
213
213
  * or the response returned by the server depending on the configuration passed.
214
- * @param {CustomGrantConfig} config - The config object contains attributes that would be used
214
+ * @param {TokenExchangeRequestConfig} config - The config object contains attributes that would be used
215
215
  * to configure the custom grant request.
216
216
  *
217
217
  * @param {string} userId - The userId of the user.
218
218
  * (If you are using ExpressJS, you may get this from the request cookies)
219
219
  *
220
- * @return {Promise<TokenResponse | FetchResponse>} -A Promise that resolves with the token information
220
+ * @return {Promise<TokenResponse | Response>} -A Promise that resolves with the token information
221
221
  * or the response returned by the server depending on the configuration passed.
222
222
  *
223
223
  * @example
@@ -225,7 +225,7 @@ export declare class AsgardeoNodeClient<T> {
225
225
  * const config = {
226
226
  * attachToken: false,
227
227
  * data: {
228
- * client_id: "{{clientID}}",
228
+ * client_id: "{{clientId}}",
229
229
  * grant_type: "account_switch",
230
230
  * scope: "{{scope}}",
231
231
  * token: "{{token}}",
@@ -236,19 +236,19 @@ export declare class AsgardeoNodeClient<T> {
236
236
  * signInRequired: true
237
237
  * }
238
238
 
239
- * auth.requestCustomGrant(config).then((response)=>{
239
+ * auth.exchangeToken(config).then((response)=>{
240
240
  * console.log(response);
241
241
  * }).catch((error)=>{
242
242
  * console.error(error);
243
243
  * });
244
244
  * ```
245
245
  *
246
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#requestCustomGrant
246
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#exchangeToken
247
247
  *
248
248
  * @memberof AsgardeoNodeClient
249
249
  *
250
250
  */
251
- requestCustomGrant(config: CustomGrantConfig, userId?: string): Promise<TokenResponse | FetchResponse>;
251
+ exchangeToken(config: TokenExchangeRequestConfig, userId?: string): Promise<TokenResponse | Response>;
252
252
  /**
253
253
  * This method can be used to update the configurations passed into the constructor of the AsgardeoAuthClient.
254
254
  * @param {AuthClientConfig<T>} config - The config object containing the attributes
@@ -258,23 +258,23 @@ export declare class AsgardeoNodeClient<T> {
258
258
  *
259
259
  * @example
260
260
  * ```
261
- * const updateConfig = await auth.updateConfig({
262
- * signOutRedirectURL: "http://localhost:3000/sign-out"
261
+ * const reInitialize = await auth.reInitialize({
262
+ * afterSignOutUrl: "http://localhost:3000/sign-out"
263
263
  * });
264
264
  * ```
265
265
  *
266
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#updateConfig
266
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#reInitialize
267
267
  *
268
268
  * @memberof AsgardeoNodeClient
269
269
  *
270
270
  */
271
- updateConfig(config: Partial<AuthClientConfig<T>>): Promise<void>;
271
+ reInitialize(config: Partial<AuthClientConfig<T>>): Promise<void>;
272
272
  /**
273
273
  * This method returns a Promise that resolves with the response returned by the server.
274
274
  * @param {string} userId - The userId of the user.
275
275
  * (If you are using ExpressJS, you may get this from the request cookies)
276
276
  *
277
- * @return {Promise<FetchResponse>} -A Promise that resolves with the response returned by the server.
277
+ * @return {Promise<Response>} -A Promise that resolves with the response returned by the server.
278
278
  *
279
279
  * @example
280
280
  * ```
@@ -286,7 +286,7 @@ export declare class AsgardeoNodeClient<T> {
286
286
  * @memberof AsgardeoNodeClient
287
287
  *
288
288
  */
289
- revokeAccessToken(userId?: string): Promise<FetchResponse>;
289
+ revokeAccessToken(userId?: string): Promise<Response>;
290
290
  /**
291
291
  * This method refreshes the access token and returns a Promise that resolves with the new access
292
292
  * token and other relevant data.
@@ -308,7 +308,7 @@ export declare class AsgardeoNodeClient<T> {
308
308
  refreshAccessToken(userId?: string): Promise<TokenResponse>;
309
309
  /**
310
310
  * This method returns if the user has been successfully signed out or not.
311
- * @param {string} signOutRedirectURL - The URL to which the user is redirected to
311
+ * @param {string} afterSignOutUrl - The URL to which the user is redirected to
312
312
  * after signing out from the server.
313
313
  *
314
314
  * @return {boolean} - A boolean value indicating if the user has been signed out or not.
@@ -323,10 +323,10 @@ export declare class AsgardeoNodeClient<T> {
323
323
  * @memberof AsgardeoNodeClient
324
324
  *
325
325
  */
326
- static isSignOutSuccessful(signOutRedirectURL: string): boolean;
326
+ static isSignOutSuccessful(afterSignOutUrl: string): boolean;
327
327
  /**
328
328
  * This method returns if sign-out failed or not
329
- * @param {string} signOutRedirectURL - The URL to which the user is redirected to
329
+ * @param {string} afterSignOutUrl - The URL to which the user is redirected to
330
330
  * after signing out from the server.
331
331
  *
332
332
  * @return {boolean} - A boolean value indicating if sign-out failed or not.
@@ -341,6 +341,6 @@ export declare class AsgardeoNodeClient<T> {
341
341
  * @memberof AsgardeoNodeClient
342
342
  *
343
343
  */
344
- static didSignOutFail(signOutRedirectURL: string): boolean;
345
- getDataLayer(): Promise<DataLayer<T>>;
344
+ static didSignOutFail(afterSignOutUrl: string): boolean;
345
+ getStorageManager(): Promise<StorageManager<T>>;
346
346
  }
@@ -15,29 +15,29 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AuthClientConfig, BasicUserInfo, CustomGrantConfig, DataLayer, IdTokenPayload, FetchResponse, OIDCEndpoints, Store, TokenResponse } from '@asgardeo/javascript';
18
+ import { AuthClientConfig, TokenExchangeRequestConfig, StorageManager, IdTokenPayload, OIDCEndpoints, Storage, TokenResponse, User } from '@asgardeo/javascript';
19
19
  import { AuthURLCallback } from '../models';
20
20
  export declare class AsgardeoNodeCore<T> {
21
21
  private _auth;
22
22
  private _cryptoUtils;
23
23
  private _store;
24
- private _dataLayer;
25
- constructor(config: AuthClientConfig<T>, store?: Store);
26
- signIn(authURLCallback: AuthURLCallback, userID: string, authorizationCode?: string, sessionState?: string, state?: string, signInConfig?: Record<string, string | boolean>): Promise<TokenResponse>;
24
+ private _storageManager;
25
+ constructor(config: AuthClientConfig<T>, store?: Storage);
26
+ signIn(authURLCallback: AuthURLCallback, userId: string, authorizationCode?: string, sessionState?: string, state?: string, signInConfig?: Record<string, string | boolean>): Promise<TokenResponse>;
27
27
  getAuthURL(userId: string, signInConfig?: Record<string, string | boolean>): Promise<string>;
28
28
  requestAccessToken(authorizationCode: string, sessionState: string, userId: string, state: string): Promise<TokenResponse>;
29
- getIDToken(userId: string): Promise<string>;
29
+ getIdToken(userId: string): Promise<string>;
30
30
  refreshAccessToken(userId?: string): Promise<TokenResponse>;
31
- isAuthenticated(userId: string): Promise<boolean>;
31
+ isSignedIn(userId: string): Promise<boolean>;
32
32
  signOut(userId: string): Promise<string>;
33
- getBasicUserInfo(userId: string): Promise<BasicUserInfo>;
34
- getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
35
- getDecodedIDToken(userId?: string): Promise<IdTokenPayload>;
33
+ getUser(userId: string): Promise<User>;
34
+ getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
35
+ getDecodedIdToken(userId?: string): Promise<IdTokenPayload>;
36
36
  getAccessToken(userId?: string): Promise<string>;
37
- requestCustomGrant(config: CustomGrantConfig, userId?: string): Promise<TokenResponse | FetchResponse>;
38
- updateConfig(config: Partial<AuthClientConfig<T>>): Promise<void>;
39
- revokeAccessToken(userId?: string): Promise<FetchResponse>;
40
- static didSignOutFail(signOutRedirectURL: string): boolean;
41
- static isSignOutSuccessful(signOutRedirectURL: string): boolean;
42
- getDataLayer(): DataLayer<T>;
37
+ exchangeToken(config: TokenExchangeRequestConfig, userId?: string): Promise<TokenResponse | Response>;
38
+ reInitialize(config: Partial<AuthClientConfig<T>>): Promise<void>;
39
+ revokeAccessToken(userId?: string): Promise<Response>;
40
+ static didSignOutFail(afterSignOutUrl: string): boolean;
41
+ static isSignOutSuccessful(afterSignOutUrl: string): boolean;
42
+ getStorageManager(): StorageManager<T>;
43
43
  }
@@ -15,8 +15,8 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { Store } from '@asgardeo/javascript';
19
- export declare class MemoryCacheStore implements Store {
18
+ import { Storage } from '@asgardeo/javascript';
19
+ export declare class MemoryCacheStore implements Storage {
20
20
  setData(key: string, value: string): Promise<void>;
21
21
  getData(key: string): Promise<string>;
22
22
  removeData(key: string): Promise<void>;
@@ -27,5 +27,5 @@ export declare class NodeCryptoUtils implements Crypto<Buffer | string> {
27
27
  base64URLDecode(value: string): string;
28
28
  hashSha256(data: string): string | Buffer;
29
29
  generateRandomBytes(length: number): string | Buffer;
30
- verifyJwt(idToken: string, jwk: Partial<JWKInterface>, algorithms: string[], clientID: string, issuer: string, subject: string, clockTolerance?: number): Promise<boolean>;
30
+ verifyJwt(idToken: string, jwk: Partial<JWKInterface>, algorithms: string[], clientId: string, issuer: string, subject: string, clockTolerance?: number): Promise<boolean>;
31
31
  }