Skip to content

Commit

Permalink
Fix issue with jwt decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
shilgapira committed Aug 8, 2023
1 parent 6f436c5 commit 8c215fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/src/session/token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Map<String, dynamic> getTenants(Map<String, dynamic> claims) {
// JWT Decoding

Uint8List decodeEncodedFragment(String value) {
final length = value.length + 4 - value.length % 4;
final length = 4 * ((value.length + 3) / 4).floor();
final data = const Base64Decoder().convert(value.padRight(length, '='));
return data;
}
Expand Down
28 changes: 14 additions & 14 deletions lib/src/types/others.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ class SignUpDetails {

/// Used to require additional behaviors when authenticating a user.
class SignInOptions {
/// Adds additional custom claims to the user's JWT during authentication.
///
/// For example, the following code starts an OTP sign in and requests a custom claim
/// with the authenticated user's full name:
///
/// try await descope.otp.signIn(with: .email, loginId: "andy@example.com", options: [
/// .customClaims(["name": "{{user.name}}"]),
/// ])
///
/// - Important: Any custom claims added via this method are considered insecure and will
/// be nested under the `nsec` custom claim.
final Map<String, dynamic> customClaims;

/// Used to add layered security to your app by implementing Step-up authentication.
///
/// final refreshJwt = Descope.sessionManager.session?.refreshJwt;
Expand Down Expand Up @@ -68,5 +55,18 @@ class SignInOptions {
/// and refresh JWTs will be an array with an entry for each authentication method used.
final String? mfaRefreshJwt;

const SignInOptions({this.customClaims = const {}, this.stepupRefreshJwt, this.mfaRefreshJwt});
/// Adds additional custom claims to the user's JWT during authentication.
///
/// For example, the following code starts an OTP sign in and requests a custom claim
/// with the authenticated user's full name:
///
/// try await descope.otp.signIn(with: .email, loginId: "andy@example.com", options: [
/// .customClaims(["name": "{{user.name}}"]),
/// ])
///
/// - Important: Any custom claims added via this method are considered insecure and will
/// be nested under the `nsec` custom claim.
final Map<String, dynamic> customClaims;

const SignInOptions({this.stepupRefreshJwt, this.mfaRefreshJwt, this.customClaims = const {}});
}

0 comments on commit 8c215fe

Please sign in to comment.