@vardario/cognito-client 2.1.0 → 3.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.
@@ -272,7 +272,8 @@ export declare enum CognitoServiceTarget {
272
272
  ConfirmForgotPassword = "ConfirmForgotPassword",
273
273
  ResendConfirmationCode = "ResendConfirmationCode",
274
274
  UpdateUserAttributes = "UpdateUserAttributes",
275
- VerifyUserAttribute = "VerifyUserAttribute"
275
+ VerifyUserAttribute = "VerifyUserAttribute",
276
+ GlobalSignOut = "GlobalSignOut"
276
277
  }
277
278
  /**
278
279
  * Cognito supported federated identities public providers.
@@ -341,8 +342,8 @@ export declare class CognitoClient {
341
342
  /**
342
343
  * Returns a new session based on the given refresh token.
343
344
  *
344
- * @param refreshToken
345
- * @param username
345
+ * @param refreshToken Refresh token from a previous session.
346
+ * @param username Username is required when using a client secret and needs to be the cognito user id.
346
347
  * @returns @see Session
347
348
  * @throws {InitiateAuthException}
348
349
  */
@@ -395,11 +396,13 @@ export declare class CognitoClient {
395
396
  */
396
397
  verifyUserAttribute(attributeName: string, code: string, accessToken: string): Promise<void>;
397
398
  /**
398
- * Sign out the user and remove the current user session.
399
+ * Revokes all of the access tokens generated by, and at the same time as, the specified refresh token. After a token is revoked, you can't use the revoked token to access Amazon Cognito user APIs, or to authorize access to your resource server.
399
400
  *
401
+ * @param refreshToken Refresh token from a previous session.
402
+ * @param username Username is required when using a client secret and needs to be the cognito user id.
400
403
  * @throws {RevokeTokenException}
401
404
  */
402
- signOut(refreshToken: string): Promise<void>;
405
+ revokeToken(refreshToken: string): Promise<void>;
403
406
  /**
404
407
  * Request forgot password.
405
408
  * @param username Username
@@ -450,4 +453,9 @@ export declare class CognitoClient {
450
453
  * @throws {Error}
451
454
  */
452
455
  handleCodeFlow(returnUrl: string, pkce: string): Promise<Session>;
456
+ /**
457
+ * Invalidates the identity, access, and refresh tokens that Amazon Cognito issued to a user. Call this operation when your user signs out of your app. This results in the following behavior.
458
+ * @param accessToken Access token of the current user.
459
+ */
460
+ globalSignOut(accessToken: string): Promise<void>;
453
461
  }
@@ -20,6 +20,7 @@ export var CognitoServiceTarget;
20
20
  CognitoServiceTarget["ResendConfirmationCode"] = "ResendConfirmationCode";
21
21
  CognitoServiceTarget["UpdateUserAttributes"] = "UpdateUserAttributes";
22
22
  CognitoServiceTarget["VerifyUserAttribute"] = "VerifyUserAttribute";
23
+ CognitoServiceTarget["GlobalSignOut"] = "GlobalSignOut";
23
24
  })(CognitoServiceTarget || (CognitoServiceTarget = {}));
24
25
  /**
25
26
  * Cognito supported federated identities public providers.
@@ -167,8 +168,8 @@ export class CognitoClient {
167
168
  /**
168
169
  * Returns a new session based on the given refresh token.
169
170
  *
170
- * @param refreshToken
171
- * @param username
171
+ * @param refreshToken Refresh token from a previous session.
172
+ * @param username Username is required when using a client secret and needs to be the cognito user id.
172
173
  * @returns @see Session
173
174
  * @throws {InitiateAuthException}
174
175
  */
@@ -274,14 +275,17 @@ export class CognitoClient {
274
275
  await cognitoRequest(verifyUserAttributePayload, CognitoServiceTarget.VerifyUserAttribute, this.cognitoEndpoint);
275
276
  }
276
277
  /**
277
- * Sign out the user and remove the current user session.
278
+ * Revokes all of the access tokens generated by, and at the same time as, the specified refresh token. After a token is revoked, you can't use the revoked token to access Amazon Cognito user APIs, or to authorize access to your resource server.
278
279
  *
280
+ * @param refreshToken Refresh token from a previous session.
281
+ * @param username Username is required when using a client secret and needs to be the cognito user id.
279
282
  * @throws {RevokeTokenException}
280
283
  */
281
- async signOut(refreshToken) {
284
+ async revokeToken(refreshToken) {
282
285
  const revokeTokenPayload = {
283
286
  Token: refreshToken,
284
- ClientId: this.userPoolClientId
287
+ ClientId: this.userPoolClientId,
288
+ ClientSecret: this.clientSecret
285
289
  };
286
290
  await cognitoRequest(revokeTokenPayload, CognitoServiceTarget.RevokeToken, this.cognitoEndpoint);
287
291
  }
@@ -414,4 +418,14 @@ export class CognitoClient {
414
418
  });
415
419
  return session;
416
420
  }
421
+ /**
422
+ * Invalidates the identity, access, and refresh tokens that Amazon Cognito issued to a user. Call this operation when your user signs out of your app. This results in the following behavior.
423
+ * @param accessToken Access token of the current user.
424
+ */
425
+ async globalSignOut(accessToken) {
426
+ const globalSignOutPayload = {
427
+ AccessToken: accessToken
428
+ };
429
+ await cognitoRequest(globalSignOutPayload, CognitoServiceTarget.GlobalSignOut, this.cognitoEndpoint);
430
+ }
417
431
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vardario/cognito-client",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Sahin Vardar",
@@ -16,8 +16,9 @@
16
16
  "scripts": {
17
17
  "build": "tsc --build",
18
18
  "format": "prettier --plugin-search-dir . --write . && prettier-package-json --write && eslint --fix .",
19
+ "integration-test": "vitest run integration",
19
20
  "prepare": "husky install",
20
- "test": "vitest run",
21
+ "test": "vitest run unit",
21
22
  "watch": "tsc --build --watch"
22
23
  },
23
24
  "dependencies": {
@@ -27,7 +28,7 @@
27
28
  "jsbn": "^1.1.0"
28
29
  },
29
30
  "devDependencies": {
30
- "@aws-sdk/client-cognito-identity-provider": "^3.454.0",
31
+ "@aws-sdk/client-cognito-identity-provider": "^3.465.0",
31
32
  "@types/jsbn": "^1.2.33",
32
33
  "@types/jsdom": "^21.1.5",
33
34
  "@types/randombytes": "^2.0.3",