import 'dart:convert'; import 'package:Envelope/utils/encryption/crypto_utils.dart'; import 'package:flutter/services.dart'; import 'package:pointycastle/impl.dart'; class DeviceToken { String id; String userId; String token; String type; DeviceToken({ required this.id, required this.userId, required this.token, required this.type, }); factory DeviceToken.fromJson(Map json, String userId, RSAPrivateKey privKey) { Uint8List token = CryptoUtils.rsaDecrypt( base64.decode(json['token']), privKey, ); Uint8List type = CryptoUtils.rsaDecrypt( base64.decode(json['device_type']), privKey, ); return DeviceToken( id: json['id'], userId: userId, token: String.fromCharCodes(token), type: String.fromCharCodes(type), ); } Map toMap() { return { 'id': id, 'user_id': userId, 'token': token, 'type': type, }; } }