getRequestUrl method
Implementation
Future<String> getRequestUrl() async {
logger.info('Creating Request Url');
if (_signature == null) {
throw signatureNotFoundError('Signature is not set.');
}
try {
final requestedProof = _getRequestedProof();
validateSignature(_providerId, _signature!, _applicationId, _timeStamp);
final templateData = TemplateData(
sessionId: _sessionId,
providerId: _providerId,
applicationId: _applicationId,
signature: _signature!,
timestamp: _timeStamp,
callbackUrl: getAppCallbackUrl(),
context: jsonEncode(_context),
parameters: getFilledParameters(requestedProof),
redirectUrl: _redirectUrl ?? '',
acceptAiProviders: _options?.acceptAiProviders ?? false,
sdkVersion: _sdkVersion ?? '',
);
await updateSession(_sessionId, SessionStatus.SESSION_STARTED);
if (_options?.useAppClip == true) {
String template = Uri.encodeComponent(jsonEncode(templateData));
template = template.replaceAll('(', '%28').replaceAll(')', '%29');
// check if the device is running on iOS or Android
final isIos = Platform.isIOS;
if (!isIos) {
final instantAppUrl =
'https://share.reclaimprotocol.org/verify/?template=$template';
logger.info('Instant App Url created successfully: $instantAppUrl');
return instantAppUrl;
} else {
final appClipUrl =
'https://appclip.apple.com/id?p=org.reclaimprotocol.app.clip&template=$template';
logger.info('App Clip Url created successfully: $appClipUrl');
return appClipUrl;
}
} else {
final link = await createLinkWithTemplateData(templateData);
logger.info('Request Url created successfully: $link');
return link;
}
} catch (error) {
logger.info('Error creating Request Url: $error');
rethrow;
}
}