Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.mdns.eu/nextcloud/passwords-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Exception')
-rw-r--r--src/Exception/ChallengeTypeNotSupported.js16
-rw-r--r--src/Exception/ConfigruationError.js9
-rw-r--r--src/Exception/Encryption/EncryptionNotEnabledError.js13
-rw-r--r--src/Exception/Encryption/InvalidEncryptedTextLength.js17
-rw-r--r--src/Exception/Encryption/InvalidObjectTypeError.js16
-rw-r--r--src/Exception/Encryption/MissingEncryptionKeyError.js16
-rw-r--r--src/Exception/Encryption/UnsupportedEncryptionTypeError.js38
-rw-r--r--src/Exception/Http/BadGatewayError.js18
-rw-r--r--src/Exception/Http/BadRequestError.js18
-rw-r--r--src/Exception/Http/ForbiddenError.js18
-rw-r--r--src/Exception/Http/GatewayTimeoutError.js18
-rw-r--r--src/Exception/Http/HttpError.js42
-rw-r--r--src/Exception/Http/InternalServerError.js18
-rw-r--r--src/Exception/Http/MethodNotAllowedError.js18
-rw-r--r--src/Exception/Http/NotFoundError.js18
-rw-r--r--src/Exception/Http/ServiceUnavailableError.js18
-rw-r--r--src/Exception/Http/TooManyRequestsError.js18
-rw-r--r--src/Exception/Http/UnauthorizedError.js18
-rw-r--r--src/Exception/InvalidScopeError.js16
-rw-r--r--src/Exception/NetworkError.js24
-rw-r--r--src/Exception/PassLink/InvalidLink.js13
-rw-r--r--src/Exception/PassLink/UnknownAction.js16
-rw-r--r--src/Exception/ResponseContentTypeError.js27
-rw-r--r--src/Exception/ResponseDecodingError.js40
-rw-r--r--src/Exception/TokenTypeNotSupported.js16
-rw-r--r--src/Exception/UnknownPropertyError.js34
26 files changed, 533 insertions, 0 deletions
diff --git a/src/Exception/ChallengeTypeNotSupported.js b/src/Exception/ChallengeTypeNotSupported.js
new file mode 100644
index 0000000..5c57223
--- /dev/null
+++ b/src/Exception/ChallengeTypeNotSupported.js
@@ -0,0 +1,16 @@
+export default class ChallengeTypeNotSupported extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'ChallengeTypeNotSupported';
+ }
+
+ /**
+ *
+ */
+ constructor() {
+ super('The required authentication challenge is not supported by this client');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/ConfigruationError.js b/src/Exception/ConfigruationError.js
new file mode 100644
index 0000000..12bb57e
--- /dev/null
+++ b/src/Exception/ConfigruationError.js
@@ -0,0 +1,9 @@
+export default class ConfigurationError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'ConfigurationError';
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Encryption/EncryptionNotEnabledError.js b/src/Exception/Encryption/EncryptionNotEnabledError.js
new file mode 100644
index 0000000..6f6bad9
--- /dev/null
+++ b/src/Exception/Encryption/EncryptionNotEnabledError.js
@@ -0,0 +1,13 @@
+export default class EncryptionNotEnabledError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'EncryptionNotEnabledError';
+ }
+
+ constructor() {
+ super(`CSE Encryption not enabled or ready`);
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Encryption/InvalidEncryptedTextLength.js b/src/Exception/Encryption/InvalidEncryptedTextLength.js
new file mode 100644
index 0000000..8760a11
--- /dev/null
+++ b/src/Exception/Encryption/InvalidEncryptedTextLength.js
@@ -0,0 +1,17 @@
+export default class InvalidEncryptedTextLength extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'InvalidEncryptedTextLength';
+ }
+
+ /**
+ * @param {Number} length
+ * @param {Number} expectedLength
+ */
+ constructor(length, expectedLength) {
+ super(`Invalid encrypted text length. Expected ${expectedLength}, got ${length} instead.`);
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Encryption/InvalidObjectTypeError.js b/src/Exception/Encryption/InvalidObjectTypeError.js
new file mode 100644
index 0000000..260e6b7
--- /dev/null
+++ b/src/Exception/Encryption/InvalidObjectTypeError.js
@@ -0,0 +1,16 @@
+export default class InvalidObjectTypeError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'InvalidObjectTypeError';
+ }
+
+ /**
+ * @param {String} type
+ */
+ constructor(type) {
+ super(`Invalid Object Type "${type}"`);
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Encryption/MissingEncryptionKeyError.js b/src/Exception/Encryption/MissingEncryptionKeyError.js
new file mode 100644
index 0000000..d753b06
--- /dev/null
+++ b/src/Exception/Encryption/MissingEncryptionKeyError.js
@@ -0,0 +1,16 @@
+export default class MissingEncryptionKeyError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'MissingEncryptionKeyError';
+ }
+
+ /**
+ * @param {String} id
+ */
+ constructor(id) {
+ super(`Requested encryption key ${id} not found`);
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Encryption/UnsupportedEncryptionTypeError.js b/src/Exception/Encryption/UnsupportedEncryptionTypeError.js
new file mode 100644
index 0000000..2858909
--- /dev/null
+++ b/src/Exception/Encryption/UnsupportedEncryptionTypeError.js
@@ -0,0 +1,38 @@
+export default class UnsupportedEncryptionTypeError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'UnsupportedEncryptionTypeError';
+ }
+
+ /**
+ * @returns {String}
+ */
+ get supportedTypes() {
+ return this._supportedTypes;
+ }
+
+ /**
+ * @returns {Object}
+ */
+ get object() {
+ return this._object;
+ }
+
+ /**
+ * @param {Object} object
+ * @param {(String|String[])} supportedTypes
+ */
+ constructor(object, supportedTypes) {
+ if(Array.isArray(supportedTypes)) {
+ supportedTypes = supportedTypes.join(', ');
+ }
+
+ super(`Unsupported encryption type "${object.cseType}" in ${object.id}. Supported types are ${supportedTypes}.`);
+
+ this._object = object;
+ this._supportedTypes = supportedTypes;
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/BadGatewayError.js b/src/Exception/Http/BadGatewayError.js
new file mode 100644
index 0000000..6395aaa
--- /dev/null
+++ b/src/Exception/Http/BadGatewayError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class BadGatewayError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'BadGatewayError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Bad Gateway');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/BadRequestError.js b/src/Exception/Http/BadRequestError.js
new file mode 100644
index 0000000..49471fe
--- /dev/null
+++ b/src/Exception/Http/BadRequestError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class BadRequestError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'BadRequestError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Bad Request');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/ForbiddenError.js b/src/Exception/Http/ForbiddenError.js
new file mode 100644
index 0000000..63a79a8
--- /dev/null
+++ b/src/Exception/Http/ForbiddenError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class ForbiddenError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'ForbiddenError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Forbidden');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/GatewayTimeoutError.js b/src/Exception/Http/GatewayTimeoutError.js
new file mode 100644
index 0000000..f5bdb0e
--- /dev/null
+++ b/src/Exception/Http/GatewayTimeoutError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class GatewayTimeoutError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'GatewayTimeoutError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Gateway Timeout');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/HttpError.js b/src/Exception/Http/HttpError.js
new file mode 100644
index 0000000..e86dfed
--- /dev/null
+++ b/src/Exception/Http/HttpError.js
@@ -0,0 +1,42 @@
+export default class HttpError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'HttpError';
+ }
+
+ /**
+ * @returns {Response}
+ */
+ get response() {
+ return this._response;
+ }
+
+ /**
+ * @returns {Number}
+ */
+ get status() {
+ return this._status;
+ }
+
+ /**
+ *
+ * @param {Response} response
+ * @param {String} statusText
+ */
+ constructor(response, statusText = '') {
+ let message = `HTTP ${response.status}`;
+
+ if(statusText.length !== 0) {
+ message += ` - ${statusText}`;
+ } else if(response.statusText.length !== 0) {
+ message += ` - ${response.statusText}`;
+ }
+
+ super(message);
+ this._response = response;
+ this._status = response.status;
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/InternalServerError.js b/src/Exception/Http/InternalServerError.js
new file mode 100644
index 0000000..7797886
--- /dev/null
+++ b/src/Exception/Http/InternalServerError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class InternalServerError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'InternalServerError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Internal Server Error');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/MethodNotAllowedError.js b/src/Exception/Http/MethodNotAllowedError.js
new file mode 100644
index 0000000..38e252c
--- /dev/null
+++ b/src/Exception/Http/MethodNotAllowedError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class MethodNotAllowedError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'MethodNotAllowedError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Method Not Allowed');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/NotFoundError.js b/src/Exception/Http/NotFoundError.js
new file mode 100644
index 0000000..cf0c451
--- /dev/null
+++ b/src/Exception/Http/NotFoundError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class NotFoundError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'NotFoundError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Not Found');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/ServiceUnavailableError.js b/src/Exception/Http/ServiceUnavailableError.js
new file mode 100644
index 0000000..6b0d67b
--- /dev/null
+++ b/src/Exception/Http/ServiceUnavailableError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class ServiceUnavailableError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'ServiceUnavailableError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Service Unavailable');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/TooManyRequestsError.js b/src/Exception/Http/TooManyRequestsError.js
new file mode 100644
index 0000000..192f560
--- /dev/null
+++ b/src/Exception/Http/TooManyRequestsError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class TooManyRequestsError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'TooManyRequestsError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Too Many Requests');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/Http/UnauthorizedError.js b/src/Exception/Http/UnauthorizedError.js
new file mode 100644
index 0000000..4d24695
--- /dev/null
+++ b/src/Exception/Http/UnauthorizedError.js
@@ -0,0 +1,18 @@
+import HttpError from './HttpError';
+
+export default class UnauthorizedError extends HttpError {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'UnauthorizedError';
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(response, 'Unauthorized');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/InvalidScopeError.js b/src/Exception/InvalidScopeError.js
new file mode 100644
index 0000000..0970abb
--- /dev/null
+++ b/src/Exception/InvalidScopeError.js
@@ -0,0 +1,16 @@
+export default class InvalidScopeError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'InvalidScopeError';
+ }
+
+ /**
+ * @param {String} scope
+ */
+ constructor(scope) {
+ super(`Invalid scope ${scope}`);
+ }
+} \ No newline at end of file
diff --git a/src/Exception/NetworkError.js b/src/Exception/NetworkError.js
new file mode 100644
index 0000000..1758fef
--- /dev/null
+++ b/src/Exception/NetworkError.js
@@ -0,0 +1,24 @@
+export default class NetworkError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'NetworkError';
+ }
+
+ /**
+ * @returns {Response}
+ */
+ get response() {
+ return this._response;
+ }
+
+ /**
+ * @param {Response} response
+ */
+ constructor(response) {
+ super(`Network error`);
+ this._response = response;
+ }
+} \ No newline at end of file
diff --git a/src/Exception/PassLink/InvalidLink.js b/src/Exception/PassLink/InvalidLink.js
new file mode 100644
index 0000000..641df63
--- /dev/null
+++ b/src/Exception/PassLink/InvalidLink.js
@@ -0,0 +1,13 @@
+export default class InvalidLink extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'InvalidLink';
+ }
+
+ constructor() {
+ super('Invalid PassLink given');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/PassLink/UnknownAction.js b/src/Exception/PassLink/UnknownAction.js
new file mode 100644
index 0000000..f809829
--- /dev/null
+++ b/src/Exception/PassLink/UnknownAction.js
@@ -0,0 +1,16 @@
+export default class InvalidLink extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'InvalidLink';
+ }
+
+ /**
+ * @param {String} action
+ */
+ constructor(action) {
+ super(`Unknown PassLink action ${action}`);
+ }
+} \ No newline at end of file
diff --git a/src/Exception/ResponseContentTypeError.js b/src/Exception/ResponseContentTypeError.js
new file mode 100644
index 0000000..5594343
--- /dev/null
+++ b/src/Exception/ResponseContentTypeError.js
@@ -0,0 +1,27 @@
+export default class ResponseContentTypeError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'ResponseContentTypeError';
+ }
+
+ /**
+ * @returns {Response}
+ */
+ get response() {
+ return this._response;
+ }
+
+ /**
+ * @param {String} expectedType
+ * @param {String} actualType
+ * @param {Response} response
+ */
+ constructor(expectedType, actualType, response) {
+ super(`Expected ${expectedType}, got ${actualType}`);
+
+ this._response = response;
+ }
+} \ No newline at end of file
diff --git a/src/Exception/ResponseDecodingError.js b/src/Exception/ResponseDecodingError.js
new file mode 100644
index 0000000..278da73
--- /dev/null
+++ b/src/Exception/ResponseDecodingError.js
@@ -0,0 +1,40 @@
+export default class ResponseDecodingError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'ResponseDecodingError';
+ }
+
+ /**
+ * @returns {Response}
+ */
+ get response() {
+ return this._response;
+ }
+
+ /**
+ * @returns {Error}
+ */
+ get error() {
+ return this._error;
+ }
+
+ /**
+ * @param {Response} response
+ * @param {Error} error
+ * @param {String} message
+ */
+ constructor(response, error, message = '') {
+
+ if(message.length === 0) {
+ message = error.message;
+ }
+
+ super(message);
+
+ this._response = response;
+ this._error = error;
+ }
+} \ No newline at end of file
diff --git a/src/Exception/TokenTypeNotSupported.js b/src/Exception/TokenTypeNotSupported.js
new file mode 100644
index 0000000..cb27fee
--- /dev/null
+++ b/src/Exception/TokenTypeNotSupported.js
@@ -0,0 +1,16 @@
+export default class TokenTypeNotSupported extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'TokenTypeNotSupported';
+ }
+
+ /**
+ *
+ */
+ constructor() {
+ super('None of the available tokens are supported by this client.');
+ }
+} \ No newline at end of file
diff --git a/src/Exception/UnknownPropertyError.js b/src/Exception/UnknownPropertyError.js
new file mode 100644
index 0000000..0ff193d
--- /dev/null
+++ b/src/Exception/UnknownPropertyError.js
@@ -0,0 +1,34 @@
+export default class UnknownPropertyError extends Error {
+
+ /**
+ * @returns {String}
+ */
+ get name() {
+ return 'UnknownPropertyError';
+ }
+
+ /**
+ * @returns {String}
+ */
+ get item() {
+ return this._item;
+ }
+
+ /**
+ * @returns {String}
+ */
+ get property() {
+ return this._property;
+ }
+
+ /**
+ * @param {String} property
+ * @param {String} item
+ */
+ constructor(property, item) {
+ super(`Read access to unknown property ${property}`);
+
+ this._property = property;
+ this._item = item;
+ }
+} \ No newline at end of file