From bab4edcabc16d7547ad0828d2b8566751c113d44 Mon Sep 17 00:00:00 2001 From: binsky Date: Mon, 25 May 2026 16:50:25 +0200 Subject: [PATCH 01/17] update gitignore, add vendor and composer.lock Signed-off-by: binsky --- .gitignore | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e765ef7b0..b9960e21e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,18 @@ -node_modules +# IDE stuff .idea +.vscode + +# dependencies +node_modules +vendor + +# artifacts .sass-cache npm-debug.log +dist -# Don't mess with other dev's config +# don't mess with other dev's config launch_phpunit.sh -dist + +# since we are using only dev dependencies atm, we can exclude it from polluting the repo +composer.lock From e42ad3a3dbd45ebd852923cf326df5a8815b8c66 Mon Sep 17 00:00:00 2001 From: binsky Date: Sat, 10 Jan 2026 19:09:35 +0100 Subject: [PATCH 02/17] use constants providing the app id needed in the app's frontend and backend --- appinfo/info.xml | 2 +- js/app/app.js | 7 +- js/app/app_public.js | 11 +- js/app/controllers/settings.js | 6 +- js/app/controllers/share.js | 6 +- js/app/controllers/vaultreqdeletion.js | 10 +- js/app/directives/icon.js | 4 +- js/app/directives/iconpicker.js | 4 +- js/app/services/credentialservice.js | 16 +- js/app/services/fileservice.js | 10 +- js/app/services/iconservice.js | 6 +- js/app/services/settingsservice.js | 6 +- js/app/services/shareservice.js | 32 ++-- js/app/services/urlservice.js | 52 ++++++ js/app/services/vaultservice.js | 20 +-- js/importers/importer-randomdata.js | 6 +- js/settings-admin.js | 13 +- lib/Search/Provider.php | 2 +- lib/Service/CredentialService.php | 3 +- lib/Service/NotificationService.php | 17 +- templates/_config.php | 6 + templates/admin.php | 8 +- templates/bookmarklet.php | 138 ++++++++-------- templates/main.php | 211 +++++++++++++------------ templates/public_share.php | 110 ++++++------- 25 files changed, 395 insertions(+), 311 deletions(-) create mode 100644 js/app/services/urlservice.js create mode 100644 templates/_config.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 1b2127205..c78e227e8 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -59,7 +59,7 @@ For an demo of this app visit [https://demo.passman.cc](https://demo.passman.cc) Passwords - passman.Page.index + passman-next.Page.index 10 diff --git a/js/app/app.js b/js/app/app.js index 0a151ea38..880e78b9b 100644 --- a/js/app/app.js +++ b/js/app/app.js @@ -23,6 +23,8 @@ (function() { 'use strict'; + const APP_ID = 'passman-next'; + /** * @ngdoc overview * @name passmanApp @@ -84,13 +86,14 @@ localStorageServiceProvider.setNotify(true, true); }).config(function($translateProvider) { $translateProvider.useSanitizeValueStrategy('sanitizeParameters'); - $translateProvider.useUrlLoader(OC.generateUrl('/apps/passman/api/v2/language')); + $translateProvider.useUrlLoader(OC.generateUrl('/apps/' + APP_ID + '/api/v2/language')); $translateProvider.preferredLanguage('en'); }).run([ '$rootScope', function($rootScope) { $rootScope.$on('$routeChangeSuccess', function(e, curr, prev) { $('.ui-dialog-content').dialog('close'); }); + $rootScope.APP_ID = APP_ID; }]); /** @@ -120,4 +123,4 @@ angular.element('#app-content-wrapper').scope().$apply(); }); }); -}()); \ No newline at end of file +}()); diff --git a/js/app/app_public.js b/js/app/app_public.js index bdbef7432..716af92d3 100644 --- a/js/app/app_public.js +++ b/js/app/app_public.js @@ -23,6 +23,8 @@ (function () { 'use strict'; + const APP_ID = 'passman-next'; + angular .module('passmanApp', [ 'ngAnimate', @@ -38,7 +40,10 @@ /** global: oc_requesttoken */ $httpProvider.defaults.headers.common.requesttoken = oc_requesttoken; }]).config(function ($translateProvider) { - $translateProvider.useUrlLoader(OC.generateUrl('/apps/passman/api/v2/language')); + $translateProvider.useUrlLoader(OC.generateUrl('/apps/' + APP_ID + '/api/v2/language')); $translateProvider.preferredLanguage('en'); - }); -}()); \ No newline at end of file + }).run([ + '$rootScope', function($rootScope) { + $rootScope.APP_ID = APP_ID; + }]); +}()); diff --git a/js/app/controllers/settings.js b/js/app/controllers/settings.js index 19a2c2ccc..634dc01c4 100644 --- a/js/app/controllers/settings.js +++ b/js/app/controllers/settings.js @@ -32,8 +32,8 @@ * Controller of the passmanApp */ angular.module('passmanApp') - .controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http', 'EncryptService', 'NotificationService', '$sce', '$translate', - function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http, EncryptService, NotificationService, $sce, $translate) { + .controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', 'UrlService', '$location', '$routeParams', '$http', 'EncryptService', 'NotificationService', '$sce', '$translate', + function ($scope, $rootScope, SettingsService, VaultService, CredentialService, UrlService, $location, $routeParams, $http, EncryptService, NotificationService, $sce, $translate) { $scope.vault_settings = {}; $scope.new_vault_name = ''; $scope.showGenericImport = false; @@ -147,7 +147,7 @@ }; var getPassmanVersion = function () { - var url = OC.generateUrl('apps/passman/api/internal/version'); + var url = UrlService.generateUrl('/api/internal/version'); $http.get(url).then(function (result) { $scope.passman_version = result.data.version; }); diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index b34ec9660..af5be83eb 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -32,8 +32,8 @@ * This file is part of passman, licensed under AGPLv3 */ angular.module('passmanApp') - .controller('ShareCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', 'NotificationService', 'SharingACL', 'EncryptService', '$translate', '$rootScope', - function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService, NotificationService, SharingACL, EncryptService, $translate, $rootScope) { + .controller('ShareCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', 'NotificationService', 'SharingACL', 'EncryptService', 'UrlService', '$translate', '$rootScope', + function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService, NotificationService, SharingACL, EncryptService, UrlService, $translate, $rootScope) { $scope.active_vault = VaultService.getActiveVault(); @@ -305,7 +305,7 @@ var port; var defaultPort = ($location.$$protocol === 'http') ? 80 : 443; port = (defaultPort !== $location.$$port) ? ':'+ $location.$$port : ''; - return $location.$$protocol + '://' + $location.$$host + port + OC.generateUrl('apps/passman/share/public#') + hash; + return $location.$$protocol + '://' + $location.$$host + port + UrlService.generateUrl('/share/public#') + hash; }; $scope.sharing_complete = true; diff --git a/js/app/controllers/vaultreqdeletion.js b/js/app/controllers/vaultreqdeletion.js index 7534c3485..d11d2a8e7 100644 --- a/js/app/controllers/vaultreqdeletion.js +++ b/js/app/controllers/vaultreqdeletion.js @@ -31,15 +31,15 @@ * Controller of the passmanApp */ angular.module('passmanApp') - .controller('RequestDeleteCtrl', ['$scope', '$location', '$http', '$routeParams', 'VaultService', 'NotificationService', '$translate', - function ($scope, $location, $http, $routeParams, VaultService, NotificationService, $translate) { + .controller('RequestDeleteCtrl', ['$scope', '$location', '$http', '$routeParams', 'VaultService', 'NotificationService', 'UrlService', '$translate', + function ($scope, $location, $http, $routeParams, VaultService, NotificationService, UrlService, $translate) { $scope.reason = ''; VaultService.getVault({guid: $routeParams.vault_id}).then(function(vault){ $scope.pending_deletion = vault.delete_request_pending; }); $scope.requestDeletion = function () { - var queryUrl = OC.generateUrl('apps/passman/admin/request-deletion/'+ $routeParams.vault_id); + var queryUrl = UrlService.generateUrl('/admin/request-deletion/'+ $routeParams.vault_id); var params = { reason: $scope.reason }; @@ -51,11 +51,11 @@ }; $scope.removeRequestDeletion = function () { - var queryUrl = OC.generateUrl('apps/passman/admin/request-deletion/' + $routeParams.vault_id); + var queryUrl = UrlService.generateUrl('/admin/request-deletion/' + $routeParams.vault_id); $http.delete(queryUrl).then(function () { NotificationService.showNotification($translate.instant('deletion.removed'), 5000); $location.path('#/'); }); }; }]); -}()); \ No newline at end of file +}()); diff --git a/js/app/directives/icon.js b/js/app/directives/icon.js index 72efc9230..7b63bbee5 100644 --- a/js/app/directives/icon.js +++ b/js/app/directives/icon.js @@ -30,7 +30,7 @@ * # passwordGen */ angular.module('passmanApp').directive('credentialIcon', [ - '$window', function($window) { + '$window', 'UrlService', function($window, UrlService) { return { template: '', restrict: 'E', @@ -47,7 +47,7 @@ } else { if(scope.credential.url) { var url = window.btoa(angular.copy(scope.credential.url)).replace('/', '_'); - scope.iconUrl = OC.generateUrl('apps/passman/api/v2/icon/') + url + '/' + + scope.iconUrl = UrlService.generateUrl('/api/v2/icon/') + url + '/' + scope.credential.credential_id; } } diff --git a/js/app/directives/iconpicker.js b/js/app/directives/iconpicker.js index e6a78f7d1..7ee2ddf98 100644 --- a/js/app/directives/iconpicker.js +++ b/js/app/directives/iconpicker.js @@ -30,7 +30,7 @@ * # passwordGen */ angular.module('passmanApp').directive('iconPicker', [ - '$window', 'IconService', '$http', 'NotificationService','$translate', function($window, IconService, $http, NotificationService, $translate) { + '$window', 'IconService', '$http', 'NotificationService', 'UrlService', '$translate', function($window, IconService, $http, NotificationService, UrlService, $translate) { return { templateUrl: 'views/partials/icon-picker.html', restrict: 'A', @@ -117,7 +117,7 @@ scope.refreshUrlIcon = function(){ NotificationService.showNotification($translate.instant('use.icon.refresh.trying'), 5000); - var queryUrl = OC.generateUrl('apps/passman/api/v2/geticon/'+btoa(scope.credential.url)); + var queryUrl = UrlService.generateUrl('/api/v2/geticon/'+btoa(scope.credential.url)); $http.get(queryUrl).then(function (response) { if(typeof response.data.content !== 'undefined'){ scope.customIcon = {}; diff --git a/js/app/services/credentialservice.js b/js/app/services/credentialservice.js index 4f830dfa2..54abd90e3 100644 --- a/js/app/services/credentialservice.js +++ b/js/app/services/credentialservice.js @@ -30,7 +30,7 @@ * Service in the passmanApp. */ angular.module('passmanApp') - .service('CredentialService', ['$http', 'EncryptService', 'VaultService', 'FileService', function ($http, EncryptService, VaultService, FileService) { + .service('CredentialService', ['$http', 'EncryptService', 'VaultService', 'FileService', 'UrlService', function ($http, EncryptService, VaultService, FileService, UrlService) { var credential = { 'credential_id': null, 'guid': null, @@ -72,7 +72,7 @@ _credential.expire_time = new Date(angular.copy(credential.expire_time)).getTime() / 1000; - var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials'); + var queryUrl = UrlService.generateUrl('/api/v2/credentials'); return $http.post(queryUrl, _credential).then(function (response) { if (response.data) { return response.data; @@ -91,7 +91,7 @@ } _credential.expire_time = new Date(angular.copy(credential.expire_time)).getTime() / 1000; - const queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + credential.guid); + const queryUrl = UrlService.generateUrl('/api/v2/credentials/' + credential.guid); return $http.patch(queryUrl, _credential).then(function (response) { if (response.data) { return response.data; @@ -101,7 +101,7 @@ }); }, getCredential: function (guid) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + guid); + var queryUrl = UrlService.generateUrl('/api/v2/credentials/' + guid); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -111,7 +111,7 @@ }); }, destroyCredential: function (guid) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + guid); + var queryUrl = UrlService.generateUrl('/api/v2/credentials/' + guid); return $http.delete(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -171,7 +171,7 @@ return key; }, getRevisions: function (guid) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + guid + '/revision'); + var queryUrl = UrlService.generateUrl('/api/v2/credentials/' + guid + '/revision'); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -183,7 +183,7 @@ updateRevision: function (revision) { var _revision = angular.copy(revision); _revision.credential_data = window.btoa(JSON.stringify(_revision.credential_data)); - var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + revision.credential_data.guid + '/revision/' + revision.revision_id); + var queryUrl = UrlService.generateUrl('/api/v2/credentials/' + revision.credential_data.guid + '/revision/' + revision.revision_id); return $http.patch(queryUrl, _revision).then(function (response) { if (response.data) { return response.data; @@ -193,7 +193,7 @@ }); }, deleteRevision: function (credential_guid, revision_id) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + credential_guid + '/revision/' + revision_id); + var queryUrl = UrlService.generateUrl('/api/v2/credentials/' + credential_guid + '/revision/' + revision_id); return $http.delete(queryUrl).then(function (response) { if (response.data) { return response.data; diff --git a/js/app/services/fileservice.js b/js/app/services/fileservice.js index 395608229..902a018da 100644 --- a/js/app/services/fileservice.js +++ b/js/app/services/fileservice.js @@ -31,10 +31,10 @@ * Service in the passmanApp. */ angular.module('passmanApp') - .service('FileService', ['$http', 'EncryptService', function ($http, EncryptService) { + .service('FileService', ['$http', 'EncryptService', 'UrlService', function ($http, EncryptService, UrlService) { return { uploadFile: function (file, key) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/file'); + var queryUrl = UrlService.generateUrl('/api/v2/file'); var _file = angular.copy(file); _file.filename = EncryptService.encryptString(_file.filename, key); var data = EncryptService.encryptString(angular.copy(file.data), key); @@ -48,7 +48,7 @@ }); }, deleteFile: function (file) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/file/' + file.file_id); + var queryUrl = UrlService.generateUrl('/api/v2/file/' + file.file_id); var _file = angular.copy(file); return $http.delete(queryUrl, _file).then(function (response) { if (response.data) { @@ -59,7 +59,7 @@ }); }, getFile: function (file) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/file/' + file.file_id); + var queryUrl = UrlService.generateUrl('/api/v2/file/' + file.file_id); var _file = angular.copy(file); return $http.get(queryUrl, _file).then(function (response) { if (response.data) { @@ -80,7 +80,7 @@ * @returns {*} */ updateFile: function (file, key) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/file/' + file.file_id); + var queryUrl = UrlService.generateUrl('/api/v2/file/' + file.file_id); var _file = angular.copy(file); _file.filename = EncryptService.encryptString(_file.filename, key); var data = EncryptService.encryptString(angular.copy(file.file_data), key); diff --git a/js/app/services/iconservice.js b/js/app/services/iconservice.js index 323d484b3..55b4059b8 100644 --- a/js/app/services/iconservice.js +++ b/js/app/services/iconservice.js @@ -31,10 +31,10 @@ * Service in the passmanApp. */ angular.module('passmanApp') - .service('IconService', ['$http', function ($http) { + .service('IconService', ['UrlService', '$http', function (UrlService, $http) { return { getIcons: function () { - var queryUrl = OC.generateUrl('apps/passman/api/v2/icon/list'); + var queryUrl = UrlService.generateUrl('/api/v2/icon/list'); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -45,4 +45,4 @@ } }; }]); -}()); \ No newline at end of file +}()); diff --git a/js/app/services/settingsservice.js b/js/app/services/settingsservice.js index 70e07d429..051d84fdd 100644 --- a/js/app/services/settingsservice.js +++ b/js/app/services/settingsservice.js @@ -32,13 +32,13 @@ * Service in the passmanApp. */ angular.module('passmanApp') - .service('SettingsService', ['localStorageService', '$http', '$rootScope', function (localStorageService, $http, $rootScope) { + .service('SettingsService', ['UrlService', 'localStorageService', '$http', '$rootScope', function (UrlService, localStorageService, $http, $rootScope) { var settings = { defaultVault: null, defaultVaultPass: null }; - $http.get(OC.generateUrl('apps/passman/api/v2/settings')).then(function (response) { + $http.get(UrlService.generateUrl('/api/v2/settings')).then(function (response) { if (response.data) { settings = angular.merge(settings, response.data); $rootScope.$broadcast('settings_loaded'); @@ -63,4 +63,4 @@ } }; }]); -}()); \ No newline at end of file +}()); diff --git a/js/app/services/shareservice.js b/js/app/services/shareservice.js index 020c38865..d8bb2daff 100644 --- a/js/app/services/shareservice.js +++ b/js/app/services/shareservice.js @@ -32,7 +32,7 @@ * Service in the passmanApp. */ angular.module('passmanApp') - .service('ShareService', ['$http', 'VaultService', 'EncryptService', 'CredentialService', function ($http, VaultService, EncryptService, CredentialService) { + .service('ShareService', ['$http', 'VaultService', 'EncryptService', 'CredentialService', 'UrlService', function ($http, VaultService, EncryptService, CredentialService, UrlService) { // Setup sjcl random engine to max paranoia level and start collecting data var paranoia_level = 10; /** global: sjcl */ @@ -41,7 +41,7 @@ return { search: function (string) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/search'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/search'); return $http.post(queryUrl, {search: string}).then(function (response) { if (response.data) { return response.data; @@ -51,7 +51,7 @@ }); }, shareWithUser: function (credential, target_user_data) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/share'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/share'); return $http.post(queryUrl, { item_id: credential.credential_id, @@ -62,7 +62,7 @@ ); }, getVaultsByUser: function (userId) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/vaults/' + userId); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/vaults/' + userId); return $http.get(queryUrl, {search: userId}).then(function (response) { if (response.data) { for (var i = 0; i < response.data.length; i++) { @@ -76,7 +76,7 @@ }); }, getPendingRequests: function () { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/pending'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/pending'); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -84,7 +84,7 @@ }); }, saveSharingRequest: function (request, crypted_shared_key) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/save'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/save'); return $http.post(queryUrl, { item_guid: request.item_guid, target_vault_guid: request.target_vault_guid, @@ -94,33 +94,33 @@ }); }, declineSharingRequest: function (request) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/decline/' + request.req_id); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/decline/' + request.req_id); return $http.delete(queryUrl).then(function (response) { return response.data; }); }, unshareCredential: function (credential) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + credential.guid); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + credential.guid); return $http.delete(queryUrl).then(function (response) { return response.data; }); }, unshareCredentialFromUser: function (credential, user_id) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + credential.guid + '/' + user_id); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + credential.guid + '/' + user_id); return $http.delete(queryUrl).then(function (response) { return response.data; }); }, createPublicSharedCredential: function (shareObj) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/public'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/public'); return $http.post(queryUrl, shareObj).then(function (response) { return response.data; }); }, getPublicSharedCredential: function (credential_guid) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + credential_guid + '/public'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + credential_guid + '/public'); return $http.get(queryUrl).then(function (response) { if (response.data) { return response; @@ -133,7 +133,7 @@ }); }, getSharedCredentialACL: function (credential) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + credential.guid + '/acl'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + credential.guid + '/acl'); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -146,13 +146,13 @@ }); }, updateCredentialAcl: function (credential, acl) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + credential.guid + '/acl'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + credential.guid + '/acl'); return $http.patch(queryUrl, acl).then(function (response) { return response.data; }); }, getCredendialsSharedWithUs: function (vault_guid) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/vault/' + vault_guid + '/get'); + var queryUrl = UrlService.generateUrl('/api/v2/sharing/vault/' + vault_guid + '/get'); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -160,7 +160,7 @@ }); }, downloadSharedFile: function (credential, file) { - const queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + credential.guid + '/file/' + file.guid); + const queryUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + credential.guid + '/file/' + file.guid); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -168,7 +168,7 @@ }); }, uploadSharedFile: function (credential, file, key) { - const queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + credential.guid + '/file'); + const queryUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + credential.guid + '/file'); let _file = angular.copy(file); _file.filename = EncryptService.encryptString(_file.filename, key); const data = EncryptService.encryptString(angular.copy(file.data), key); diff --git a/js/app/services/urlservice.js b/js/app/services/urlservice.js new file mode 100644 index 000000000..3ac0c25e4 --- /dev/null +++ b/js/app/services/urlservice.js @@ -0,0 +1,52 @@ +/** + * Nextcloud - passman + * + * @copyright Copyright (c) 2016, Sander Brand (brantje@gmail.com) + * @copyright Copyright (c) 2016, Marcos Zuriaga Miguel (wolfi@wolfi.es) + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +(function () { + 'use strict'; + + /** + * @ngdoc service + * @name passmanApp.UrlService + * @description + * # UrlService + * Service in the passmanApp. + */ + angular.module('passmanApp') + .service('UrlService', ['$rootScope', function ($rootScope) { + return { + /** + * Like OC.generateUrl, but with an additional apps// prefix + * @returns {*} + */ + generateUrl: function (localAppUrl) { + let prefix = 'apps/' + $rootScope.APP_ID; + if (!localAppUrl) { + localAppUrl = ''; + } + if (!localAppUrl.startsWith('/')) { + prefix += '/'; + } + return OC.generateUrl(prefix + localAppUrl); + } + }; + }]); +}()); diff --git a/js/app/services/vaultservice.js b/js/app/services/vaultservice.js index da3eb9923..d65d4e6e4 100644 --- a/js/app/services/vaultservice.js +++ b/js/app/services/vaultservice.js @@ -32,13 +32,13 @@ * Service in the passmanApp. */ angular.module('passmanApp') - .service('VaultService', ['$http', function ($http) { + .service('VaultService', ['UrlService', '$http', function (UrlService, $http) { // AngularJS will instantiate a singleton by calling "new" on this function var _this = this; var _activeVault; var service = { getVaults: function () { - var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults'); + var queryUrl = UrlService.generateUrl('/api/v2/vaults'); return $http.get(queryUrl).then(function (response) { if (response.data) { return response.data; @@ -71,7 +71,7 @@ }, createVault: function (vaultName) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults'); + var queryUrl = UrlService.generateUrl('/api/v2/vaults'); return $http.post(queryUrl, {vault_name: vaultName}).then(function (response) { if (response.data) { return response.data; @@ -81,7 +81,7 @@ }); }, getVault: function (vault) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + vault.guid); + var queryUrl = UrlService.generateUrl('/api/v2/vaults/' + vault.guid); return $http.get(queryUrl).then(function (response) { if (response.data) { if (response.data.vault_settings) { @@ -101,7 +101,7 @@ delete _vault.defaultVault; delete _vault.vaultKey; _vault.vault_settings = window.btoa(JSON.stringify(_vault.vault_settings)); - var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + _vault.guid); + var queryUrl = UrlService.generateUrl('/api/v2/vaults/' + _vault.guid); return $http.patch(queryUrl, _vault).then(function (response) { if (response.data) { return response.data; @@ -113,7 +113,7 @@ updateSharingKeys: function (vault) { var _vault = angular.copy(vault); delete _vault.vaultKey; - var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + _vault.guid + '/sharing-keys'); + var queryUrl = UrlService.generateUrl('/api/v2/vaults/' + _vault.guid + '/sharing-keys'); return $http.post(queryUrl, _vault).then(function (response) { if (response.data) { return response.data; @@ -123,7 +123,7 @@ }); }, reEncryptACLSharingKeys: function (vault, oldVaultPass, newVaultPass, EncryptService) { - const queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/vault/' + vault.guid + '/acl'); + const queryUrl = UrlService.generateUrl('/api/v2/sharing/vault/' + vault.guid + '/acl'); return $http.get(queryUrl).then(function (response) { if (response.data) { const updateACLSharingKey = function (index) { @@ -131,7 +131,7 @@ const decrypted_shared_key = EncryptService.decryptString(angular.copy(acl.shared_key), oldVaultPass); acl.shared_key = EncryptService.encryptString(decrypted_shared_key, newVaultPass); - const patchUrl = OC.generateUrl('apps/passman/api/v2/sharing/credential/' + acl.item_guid + '/acl/shared_key'); + const patchUrl = UrlService.generateUrl('/api/v2/sharing/credential/' + acl.item_guid + '/acl/shared_key'); $http.patch(patchUrl, { shared_key: acl.shared_key }).then(function () { @@ -147,8 +147,8 @@ }); }, deleteVault: function (vault, file_ids) { - var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + vault.guid); - var deleteFilesUrl = OC.generateUrl('apps/passman/api/v2/files/delete'); + var queryUrl = UrlService.generateUrl('/api/v2/vaults/' + vault.guid); + var deleteFilesUrl = UrlService.generateUrl('/api/v2/files/delete'); var filesData = { "file_ids": JSON.stringify(file_ids) }; diff --git a/js/importers/importer-randomdata.js b/js/importers/importer-randomdata.js index c0b6929d1..9f05e2d9a 100644 --- a/js/importers/importer-randomdata.js +++ b/js/importers/importer-randomdata.js @@ -27,6 +27,8 @@ var PassmanImporter = PassmanImporter || {}; 'use strict'; // Define the importer + const APP_ID = 'passman-next'; + // Define the importer PassmanImporter.randomData = { info: { @@ -60,7 +62,7 @@ var PassmanImporter = PassmanImporter || {}; var _this = this; var generateCredential = function (max, i, callback) { if (jQuery) { - var url = OC.generateUrl('apps/passman/api/internal/generate_person'); + var url = OC.generateUrl('apps/' + APP_ID + '/api/internal/generate_person'); $.ajax({ url: url, dataType: 'json', @@ -118,4 +120,4 @@ var PassmanImporter = PassmanImporter || {}; }); }); }; -})(window, $, PassmanImporter); \ No newline at end of file +})(window, $, PassmanImporter); diff --git a/js/settings-admin.js b/js/settings-admin.js index a4f4410e1..a9fd46446 100644 --- a/js/settings-admin.js +++ b/js/settings-admin.js @@ -21,6 +21,7 @@ */ $(document).ready(function () { + const urlPrefix = 'apps/passman-next'; var Settings = function (baseUrl) { this._baseUrl = baseUrl; this._settings = []; @@ -83,7 +84,7 @@ $(document).ready(function () { }; - var settings = new Settings(OC.generateUrl('apps/passman/api/v2/settings')); + var settings = new Settings(OC.generateUrl(urlPrefix + '/api/v2/settings')); settings.load(); // ADMIN SETTINGS @@ -139,7 +140,7 @@ $(document).ready(function () { }; $('.account_mover_selector').select2({ ajax: { - url: OC.generateUrl('apps/passman/admin/search'), + url: OC.generateUrl(urlPrefix + '/admin/search'), dataType: 'json', delay: 50, data: function (param) { @@ -173,7 +174,7 @@ $(document).ready(function () { $(self).attr('disabled', 'disabled'); $(self).html(' ' + OC.L10N.translate('passman', 'Moving') + '...'); if (accountMover.source_account && accountMover.destination_account) { - $.post(OC.generateUrl('apps/passman/admin/move'), accountMover, function (data) { + $.post(OC.generateUrl(urlPrefix + '/admin/move'), accountMover, function (data) { $(self).removeAttr('disabled'); $(self).html('Move'); if (data.success) { @@ -223,14 +224,14 @@ $(document).ready(function () { if (!confirm(OC.L10N.translate('passman', "Are you really sure?\nThis will delete the vault and all credentials in it!"))) { return; } - $.post(OC.generateUrl('apps/passman/admin/accept-delete-request'), req, function () { + $.post(OC.generateUrl(urlPrefix + '/admin/accept-delete-request'), req, function () { $(el).parent().parent().remove(); }); } function ignoreDeleteRequest (el, req) { $.ajax({ - url: OC.generateUrl('apps/passman/admin/request-deletion/' + req.vault_guid), + url: OC.generateUrl(urlPrefix + '/admin/request-deletion/' + req.vault_guid), type: 'DELETE', success: function () { $(el).parent().parent().remove(); @@ -238,7 +239,7 @@ $(document).ready(function () { }); } - $.get(OC.generateUrl('apps/passman/admin/delete-requests'), function (requests) { + $.get(OC.generateUrl(urlPrefix + '/admin/delete-requests'), function (requests) { var table = $('#requests-table tbody'); $.each(requests, function (k, request) { var accept = $('[Accept] '); diff --git a/lib/Search/Provider.php b/lib/Search/Provider.php index 25ee5c3a7..f58aabe00 100644 --- a/lib/Search/Provider.php +++ b/lib/Search/Provider.php @@ -89,7 +89,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult { \sprintf("Part of Passman vault %s", $vault->getName()), sprintf( "%s#/vault/%s?show=%s&showv=%s", - $this->urlGenerator->linkToRoute('passman.Page.index'), + $this->urlGenerator->linkToRoute(Application::APP_ID . '.Page.index'), $vault->getGuid(), $credential->getGuid(), $vault->getGuid() // need to pass vault guid again, to preserve it if credential.js rewrites path to / diff --git a/lib/Service/CredentialService.php b/lib/Service/CredentialService.php index f028b25c5..dcdb89549 100644 --- a/lib/Service/CredentialService.php +++ b/lib/Service/CredentialService.php @@ -24,6 +24,7 @@ namespace OCA\Passman\Service; use OCA\Passman\Activity; +use OCA\Passman\AppInfo\Application; use OCA\Passman\Db\Credential; use OCA\Passman\Db\CredentialMapper; use OCA\Passman\Db\SharingACL; @@ -238,7 +239,7 @@ public function getDirectEditLink(Credential $credential): string { return $this->urlGenerator->getAbsoluteURL( $this->urlGenerator->linkTo( '', - 'index.php/apps/passman/#/vault/' . $vault->getGuid() . '/edit/' . $credential->getGuid() + 'index.php/apps/' . Application::APP_ID . '/#/vault/' . $vault->getGuid() . '/edit/' . $credential->getGuid() ) ); } diff --git a/lib/Service/NotificationService.php b/lib/Service/NotificationService.php index df07b9bd4..c3f0857df 100644 --- a/lib/Service/NotificationService.php +++ b/lib/Service/NotificationService.php @@ -24,6 +24,7 @@ namespace OCA\Passman\Service; +use OCA\PassmanNext\AppInfo\Application; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IURLGenerator; @@ -38,7 +39,7 @@ public function __construct( } function credentialExpiredNotification($credential, $link) { - $api = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'index.php/apps/passman')); + $api = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'index.php/apps/' . Application::APP_ID)); $notification = $this->manager->createNotification(); $remindAction = $notification->createAction(); $remindAction->setLabel('remind') @@ -48,7 +49,7 @@ function credentialExpiredNotification($credential, $link) { $declineAction->setLabel('ignore') ->setLink($api . '/api/internal/notifications/read/' . $credential->getId(), 'DELETE'); - $notification->setApp('passman') + $notification->setApp(Application::APP_ID) ->setUser($credential->getUserId()) ->setDateTime(new \DateTime()) ->setObject('credential', $credential->getId()) // Set notification type and id @@ -62,15 +63,15 @@ function credentialExpiredNotification($credential, $link) { function credentialSharedNotification($data) { - $link = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'index.php/apps/passman/#/')); - $api = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'index.php/apps/passman')); + $link = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'index.php/apps/' . Application::APP_ID . '/#/')); + $api = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'index.php/apps/' . Application::APP_ID)); $notification = $this->manager->createNotification(); $declineAction = $notification->createAction(); $declineAction->setLabel('decline') ->setLink($api . '/api/v2/sharing/decline/' . $data['req_id'], 'DELETE'); - $notification->setApp('passman') + $notification->setApp(Application::APP_ID) ->setUser($data['target_user']) ->setDateTime(new \DateTime()) ->setObject('passman_share_request', $data['req_id']) // type and id @@ -84,7 +85,7 @@ function credentialSharedNotification($data) { function credentialDeclinedSharedNotification($data) { $notification = $this->manager->createNotification(); - $notification->setApp('passman') + $notification->setApp(Application::APP_ID) ->setUser($data['target_user']) ->setDateTime(new \DateTime()) ->setObject('passman_share_request', $data['req_id']) // type and id @@ -95,7 +96,7 @@ function credentialDeclinedSharedNotification($data) { function credentialAcceptedSharedNotification($data) { $notification = $this->manager->createNotification(); - $notification->setApp('passman') + $notification->setApp(Application::APP_ID) ->setUser($data['target_user']) ->setDateTime(new \DateTime()) ->setObject('passman_share_request', $data['req_id']) // type and id @@ -122,7 +123,7 @@ function deleteNotificationsOfCredential($credential) { function markNotificationOfCredentialAsProcessed(int $credential_id, string $user_id): void { $notification = $this->manager->createNotification(); - $notification->setApp('passman') + $notification->setApp(Application::APP_ID) ->setObject('credential', $credential_id) ->setUser($user_id); $this->manager->markProcessed($notification); diff --git a/templates/_config.php b/templates/_config.php new file mode 100644 index 000000000..3af572e21 --- /dev/null +++ b/templates/_config.php @@ -0,0 +1,6 @@ +
diff --git a/templates/bookmarklet.php b/templates/bookmarklet.php index 4f9088373..6ce1f6e5f 100644 --- a/templates/bookmarklet.php +++ b/templates/bookmarklet.php @@ -1,85 +1,89 @@ diff --git a/templates/main.php b/templates/main.php index 2200a8184..d2ff5f7f7 100644 --- a/templates/main.php +++ b/templates/main.php @@ -1,122 +1,125 @@ diff --git a/templates/public_share.php b/templates/public_share.php index c718dced7..cff83ce9a 100644 --- a/templates/public_share.php +++ b/templates/public_share.php @@ -1,70 +1,74 @@