Skip to content

Commit

Permalink
replace existing container
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmer committed Oct 18, 2024
1 parent d5d0db3 commit 1838e57
Show file tree
Hide file tree
Showing 22 changed files with 933 additions and 340 deletions.
10 changes: 5 additions & 5 deletions lib/api/privacy_idea_container_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PrivacyIdeaContainerApi {
final passphrase = container.passphraseQuestion?.isNotEmpty == true ? await EnterPassphraseDialog.show(await globalContext) : null;
final message = '${container.nonce}'
'|${container.timestamp.toIso8601String().replaceFirst('Z', '+00:00')}'
'|${container.finalizationUrl}'
'|${container.registrationUrl}'
'|${container.serial}'
'|${AppInfoUtils.deviceId}'
'${passphrase != null ? '|$passphrase' : ''}';
Expand All @@ -128,15 +128,15 @@ class PrivacyIdeaContainerApi {
CONTAINER_DEVICE_ID: AppInfoUtils.deviceId,
CONTAINER_SIGNATURE: signature,
};
return await _ioClient.doPost(url: container.finalizationUrl, body: body, sslVerify: false); //TODO: sslVerify
return await _ioClient.doPost(url: container.registrationUrl, body: body, sslVerify: container.sslVerify);
}

/* //////////////////////////////
/////// PRIVATE FUNCTIONS ///////
////////////////////////////// */

Future<ContainerFinalizationChallenge?> _getChallenge(TokenContainerFinalized container) async {
final initResponse = await _ioClient.doGet(url: container.syncUrl, parameters: {CONTAINER_SERIAL: container.serial});
final initResponse = await _ioClient.doGet(url: container.syncUrlInit, parameters: {CONTAINER_SERIAL: container.serial});
if (initResponse.statusCode != 200) {
final errorResponse = initResponse.asPiErrorResponse();
if (errorResponse != null) throw errorResponse.piServerResultError;
Expand Down Expand Up @@ -175,7 +175,7 @@ class PrivacyIdeaContainerApi {
CONTAINER_DICT_TOKENS: otpAuthMaps,
};
final signMessage =
'${challenge.nonce}|${challenge.timeStamp}|${container.serial}|${challenge.finalizeSyncUrl}|$publicKeyBase64|${jsonEncode(containerDict)}';
'${challenge.nonce}|${challenge.timeStamp}|${container.serial}|${container.syncUrlFinalize}|$publicKeyBase64|${jsonEncode(containerDict)}';
Logger.debug(signMessage);
final signature = container.signMessage(signMessage);
Logger.debug('Sended container: ${jsonEncode(containerDict)}');
Expand All @@ -185,7 +185,7 @@ class PrivacyIdeaContainerApi {
CONTAINER_SYNC_DICT_CLIENT: jsonEncode(containerDict),
};

final response = await _ioClient.doPost(url: Uri.parse(challenge.finalizeSyncUrl), body: body);
final response = await _ioClient.doPost(url: container.syncUrlFinalize, body: body);
if (response.statusCode != 200) {
final piErrorResponse = response.asPiErrorResponse();
if (piErrorResponse != null) throw piErrorResponse.piServerResultError;
Expand Down
143 changes: 112 additions & 31 deletions lib/l10n/app_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
"@container": {
"description": "Title for the container view."
},
"@containerDetails": {
"description": "Title of the container details dialog."
},
"@containerSyncUrl": {
"description": "Title of the container sync url field."
},
"@couldNotSignMessage": {
"description": "Tells the user that the message could not be signed."
},
Expand All @@ -98,26 +104,25 @@
"@creator": {
"description": "Label for the creator of the token."
},
"@darkTheme": {
"description": "The dark theme."
},
"@decline": {
"description": "Label for e.g. a button. Something gets declined by the user."
},
"@delete": {
"description": "Label that describes deleting the token."
},
"@deleteContainerDialogTitle": {
"example": {
"serial": "SMPH0008CC47"
"placeholders": {
"serial": {
"example": "SMPH0008CC47"
}
}
},
"@details": {
"description": "Title of the details action Button."
},
"@deviceCredentialsRequiredTitle": {
"description": "Message showed as a title in a dialog which indicates the user has not set up credentials authentication on their device. It is used on Android side. Maximum 60 characters."
},
"@deviceCredentialsSetupDescription": {
"description": "Message advising the user to go to the settings and configure device credentials on their device. It shows in a dialog on Android side."
},
"@digits": {
"description": "Title of the dropdown button where the number of digits for the opt value is selected."
},
Expand Down Expand Up @@ -200,6 +205,9 @@
}
}
},
"@exampleUrl": {
"description": "Shows the user an example of a valid URL."
},
"@failedToFinalizeContainer": {
"description": "Error message when finalizing a container failed.",
"placeholders": {
Expand All @@ -209,7 +217,12 @@
}
},
"@failedToLoad": {
"description": "Error message when something could not be loaded."
"description": "Error message when something could not be loaded.",
"placeholders": {
"name": {
"example": "token data"
}
}
},
"@failedToSyncContainer": {
"placeholders": {
Expand All @@ -221,21 +234,56 @@
"@feedbackPrivacyPolicy2": {
"description": "Taping on this should open the privacy policy."
},
"@finalizationState": {
"description": "Title of the finalization state field."
},
"@generatingPhonePart": {
"description": "Title of a dialog telling the user that the phone part gets generated right now."
},
"@goToSettingsButton": {
"description": "Message showed on a button that the user can click to go to settings pages from the current dialog. It is used on both Android and iOS side. Maximum 30 characters."
},
"@goToSettingsDescription": {
"description": "Message advising the user to go to the settings and configure device credentials or biometrics on their device."
},
"@guide": {
"description": "Button to open the guide screen."
},
"@handshakeFailed": {
"description": "Error message when the handshake failed."
},
"@imageUrl": {
"description": "Title of the image url field."
},
"@importConflictToken": {
"placeholders": {
"count": {
"example": "5"
}
}
},
"@importExistingToken": {
"placeholders": {
"count": {
"example": "5"
}
}
},
"@importFailedToken": {
"placeholders": {
"count": {
"example": "5"
}
}
},
"@importNTokens": {
"placeholders": {
"count": {
"example": "5"
}
}
},
"@importNewToken": {
"placeholders": {
"count": {
"example": "5"
}
}
},
"@importedVia": {
"description": "Label for the import method of the token."
},
Expand All @@ -246,6 +294,34 @@
}
}
},
"@invalidBackupFile": {
"placeholders": {
"appName": {
"example": "privacyIDEA Authenticator"
}
}
},
"@invalidLink": {
"placeholders": {
"appName": {
"example": "privacyIDEA Authenticator"
}
}
},
"@invalidQrFile": {
"placeholders": {
"appName": {
"example": "privacyIDEA Authenticator"
}
}
},
"@invalidQrScan": {
"placeholders": {
"appName": {
"example": "privacyIDEA Authenticator"
}
}
},
"@invalidValue": {
"description": "Error message when the value is not valid for the parameter.",
"placeholders": {
Expand Down Expand Up @@ -282,6 +358,9 @@
"@isPiTokenQuestion": {
"description": "Label for the question if the token is a privacyIDEA token."
},
"@issuer": {
"description": "Title of the issuer field."
},
"@issuerLabel": {
"description": "Label for the issuer of the token, container... etc.",
"placeholders": {
Expand All @@ -304,9 +383,6 @@
}
}
},
"@lightTheme": {
"description": "The light theme."
},
"@linkedContainer": {
"description": "Label for the linked container serial number."
},
Expand Down Expand Up @@ -375,13 +451,6 @@
"@ok": {
"description": "Button to confirm an action."
},
"@onBoardingTitle1": {
"placeholders": {
"appName": {
"example": "privacyIDEA Authenticator"
}
}
},
"@open": {
"description": "Button to open something."
},
Expand All @@ -400,6 +469,9 @@
},
"type": "text"
},
"@patchNotesDialogTitle": {
"description": "Title of the dialog that shows the patch notes."
},
"@period": {
"description": "Title of the dropdown button where the period of the totp token is selected."
},
Expand Down Expand Up @@ -460,9 +532,6 @@
"@requestPushChallengesPeriodically": {
"description": "The description of the polling feature."
},
"@retry": {
"description": "Label for e.g. a button. Something is tried to be done again."
},
"@rolloutStateCompleted": {
"description": "Message for the rollout process"
},
Expand Down Expand Up @@ -559,6 +628,21 @@
"@syncFbTokenFailed": {
"description": "Headline for the list of tokens where the synchronization failed."
},
"@syncState": {
"description": "The state of the synchronization of the token"
},
"@syncStateCompletedDescription": {
"description": "The description of the state when the synchronization is completed"
},
"@syncStateFailedDescription": {
"description": "The description of the state when the synchronization failed"
},
"@syncStateNotStartedDescription": {
"description": "The description of the state when the synchronization is not started"
},
"@syncStateSyncingDescription": {
"description": "The description of the state when the synchronization is currently syncing"
},
"@synchronizePushTokens": {
"description": "Title of synchronizing push tokens in settings."
},
Expand All @@ -568,9 +652,6 @@
"@synchronizingTokens": {
"description": "Title of the push synchronization dialog."
},
"@systemTheme": {
"description": "The systems theme."
},
"@theSecretDoesNotFitTheCurrentEncoding": {
"description": "Hint telling the user that the secret does not fit the selected encoding."
},
Expand Down
Loading

0 comments on commit 1838e57

Please sign in to comment.