-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support user hmac hash generation
- Loading branch information
Ephraim Nartey
committed
Nov 29, 2024
1 parent
b76a707
commit 3d2de1c
Showing
7 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,42 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:equatable/equatable.dart'; | ||
import 'package:crypto/crypto.dart'; | ||
|
||
class ChatwootParameters extends Equatable { | ||
final bool isPersistenceEnabled; | ||
final String baseUrl; | ||
final String clientInstanceKey; | ||
final String inboxIdentifier; | ||
final String? userIdentifier; | ||
final String? userIdentityValidationKey; | ||
|
||
ChatwootParameters( | ||
{required this.isPersistenceEnabled, | ||
required this.baseUrl, | ||
required this.inboxIdentifier, | ||
required this.clientInstanceKey, | ||
this.userIdentifier}); | ||
this.userIdentityValidationKey}); | ||
|
||
|
||
String generateHmacHash(String key, String userIdentifier) { | ||
// Convert the key and message to bytes | ||
final keyBytes = utf8.encode(key); | ||
final messageBytes = utf8.encode(userIdentifier); | ||
|
||
// Create the HMAC using SHA256 | ||
final hmac = Hmac(sha256, keyBytes); | ||
|
||
final digest = hmac.convert(messageBytes); | ||
|
||
return digest.toString(); | ||
} | ||
|
||
@override | ||
List<Object?> get props => [ | ||
isPersistenceEnabled, | ||
baseUrl, | ||
clientInstanceKey, | ||
inboxIdentifier, | ||
userIdentifier | ||
userIdentityValidationKey | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters