1.0.24 • Published 7 years ago

@astro-my/idc-code v1.0.24

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
7 years ago

Identity Status and Error Codes

Constants enumerating the Identity status and error codes.

This package is a simple collection of all the possible error codes, identity as a whole can throw. Refer this for mapping error codes with appropriate description/messages.

All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), RFC2518 (WebDAV), RFC6585 (Additional HTTP Status Codes), and RFC7538 (Permanent Redirect) are supported.

The error codes depends on the services. Preferred naming convention is to start the error code with initial of service name, for eg any error code relating to template service will start from TS

Completely library agnostic. No dependencies.

Installation

npm install @astro-my/idc-code --save

or

yarn add @astro-my/idc-code

Usage

const ICode = require('@astro-my/idc-code');
response
	.status(ICode.HTTP.OK)
	.send('ok');

response
	.status(ICode.HTTP.INTERNAL_SERVER_ERROR)
	.send({
		error: ICode.getStatusText('HTTP.INTERNAL_SERVER_ERROR')
	});

const template = Template.findOne('123');
if(!template) {
    // it will throw 'TS001'
    throw ICode.TEMPLATE_SERVICE.TEMPLATE_NOT_FOUND;
}

For developers, who need to add their own error/status code

You need to create one new file, under codes folder. If you are creating error codes for services then for clarity, its strongly recemonded to put it under codes/services folder.

// store will give you peristent storage on disk, so that the error codes/status you are going to generate will be saved to retrive the description later on
// create is a helper function to register your service
const { store, create } = require('../../store');

const SERVICE = 'TEMPLATE_SERVICE';
// create new service in store
create(SERVICE);

// this is how you define new statuses
store[SERVICE][exports.TEMPLATE_NOT_FOUND = 'TS001'] = 'Template you are looking for doesn\'t exist';

Once done, just import this file in index.js and expose it for outer world :)

Codes

HTTP CODES

ConstantCodeStatus Text
ACCEPTED202Accepted
BAD_GATEWAY502Bad Gateway
BAD_REQUEST400Bad Request
CONFLICT409Conflict
CONTINUE100Continue
CREATED201Created
EXPECTATION_FAILED417Expectation Failed
FAILED_DEPENDENCY424Failed Dependency
FORBIDDEN403Forbidden
GATEWAY_TIMEOUT504Gateway Timeout
GONE410Gone
HTTP_VERSION_NOT_SUPPORTED505HTTP Version Not Supported
IM_A_TEAPOT418I'm a teapot
INSUFFICIENT_SPACE_ON_RESOURCE419Insufficient Space on Resource
INSUFFICIENT_STORAGE507Insufficient Storage
INTERNAL_SERVER_ERROR500Server Error
LENGTH_REQUIRED411Length Required
LOCKED423Locked
METHOD_FAILURE420Method Failure
METHOD_NOT_ALLOWED405Method Not Allowed
MOVED_PERMANENTLY301Moved Permanently
MOVED_TEMPORARILY302Moved Temporarily
MULTI_STATUS207Multi-Status
MULTIPLE_CHOICES300Multiple Choices
NETWORK_AUTHENTICATION_REQUIRED511Network Authentication Required
NO_CONTENT204No Content
NON_AUTHORITATIVE_INFORMATION203Non Authoritative Information
NOT_ACCEPTABLE406Not Acceptable
NOT_FOUND404Not Found
NOT_IMPLEMENTED501Not Implemented
NOT_MODIFIED304Not Modified
OK200OK
PARTIAL_CONTENT206Partial Content
PAYMENT_REQUIRED402Payment Required
PERMANENT_REDIRECT308Permanent Redirect
PRECONDITION_FAILED412Precondition Failed
PRECONDITION_REQUIRED428Precondition Required
PROCESSING102Processing
PROXY_AUTHENTICATION_REQUIRED407Proxy Authentication Required
REQUEST_HEADER_FIELDS_TOO_LARGE431Request Header Fields Too Large
REQUEST_TIMEOUT408Request Timeout
REQUEST_TOO_LONG413Request Entity Too Large
REQUEST_URI_TOO_LONG414Request-URI Too Long
REQUESTED_RANGE_NOT_SATISFIABLE416Requested Range Not Satisfiable
RESET_CONTENT205Reset Content
SEE_OTHER303See Other
SERVICE_UNAVAILABLE503Service Unavailable
SWITCHING_PROTOCOLS101Switching Protocols
TEMPORARY_REDIRECT307Temporary Redirect
TOO_MANY_REQUESTS429Too Many Requests
UNAUTHORIZED401Unauthorized
UNPROCESSABLE_ENTITY422Unprocessable Entity
UNSUPPORTED_MEDIA_TYPE415Unsupported Media Type
USE_PROXY305Use Proxy

Common Error Code

ConstantCodeStatus Text
SUCCESSSUCCESSSuccess
INVALID_EMAILINVALID_EMAILUser is not found
INVALID_PHONEINVALID_PHONEInvalid email format
INVALID_ACCOUNT_IDINVALID_ACCOUNT_IDInvalid account ID format
USER_ALREADY_VERIFIEDUSER_ALREADY_VERIFIEDUser is already verified

Template Service

ConstantCodeStatus Text
TEMPLATE_NOT_FOUNDTS001Template you are looking for doesn't exist
INVALID_CATEGORYTS002Invalid Category
INVALID_TYPETS003Invalid Type

OIDC Proxy Service

ConstantCodeStatus Text
SUCCESSSUCCESSSuccess
CODE_NOT_FOUNDCODE_NOT_FOUNDAuthorization code is not found
CODE_EXPIREDCODE_EXPIREDAuthorization code is expired
INVALID_GRANTINVALID_GRANTInvalid grant type
INVALID_REQUESTINVALID_REQUESTInvalid email or phone number
INVALID_CLIENT_IDINVALID_CLIENT_IDInvalid client ID
UNKNOWN_ERRORUNKNOWN_ERRORUnknown Error

Identity Middleware Portal

ConstantCodeStatus Text
PASSWORD_INVALID_LENGTH_MINPASSWORD_INVALID_LENGTH_MINCheck password length
PASSWORD_INVALID_LENGTH_MAXPASSWORD_INVALID_LENGTH_MAXCheck password length
PASSWORD_STRENGTH_WEAKPASSWORD_STRENGTH_WEAKPassword is too common. Please choose a different one.
COOKIES_NOT_FOUNDCOOKIES_NOT_FOUNDCookies not found
INVALID_COOKIEINVALID_COOKIEInvalid Cookie
SPECIAL_CHARACTER_NOT_FOUNDSPECIAL_CHARACTER_NOT_FOUNDSpecial character
NUMBER_NOT_FOUNDNUMBER_NOT_FOUNDNumbers not found
UPPERCASE_NOT_FOUNDUPPERCASE_NOT_FOUNDUppercase letter
LOWERCASE_NOT_FOUNDLOWERCASE_NOT_FOUNDLowercase letter
SUCCESSSUCCESSSuccess
CAPTCHA_VALIDINVALID_CAPTCHACaptcha is invalid

Identity Email Service

ConstantCodeStatus Text
EMAIL_GATEWAY_ERROREMAIL_GATEWAY_ERRORError when sending email
EMAIL_NOT_CONFIGUREEMAIL_NOT_CONFIGUREEmail content has not been configured by partner
EMAIL_NOT_FOUNDEMAIL_NOT_FOUNDEmail is not found

Identity Account Service

ConstantCodeStatus Text
INVALID_TOKENINVALID_TOKENToken is invalid
USER_NOT_FOUNDUSER_NOT_FOUNDUser is not found
ACCOUNT_NOT_VERIFIEDACCOUNT_NOT_VERIFIEDUser is not verified
PARTNER_NOT_CONFIGUREPARTNER_NOT_CONFIGUREPartner has not setup registration method allowed
INVALID_METHODINVALID_METHODRegistration with this method is not allowed by partne
ACCOUNT_INVALIDACCOUNT_INVALIDAccount is using external identifier
WRONG_PASSWORDWRONG_PASSWORDOld password is wrong
EMAIL_NOT_UNIQUEEMAIL_NOT_UNIQUEEmail is not unique
PHONE_NOT_UNIQUEPHONE_NOT_UNIQUEPhone number is not unique
PASSWORD_INVALIDPASSWORD_INVALIDOld and new password value are the same
ACCOUNT_LOCKEDACCOUNT_LOCKEDYour account is now locked because of too many invalid attempts. Check your email, we have sent you password reset

Identity Token Service

ConstantCodeStatus Text
INVALID_CREDENTIALSTOS001Template you are looking for doesn't exist
INVALID_GRANTTOS002Invalid Category
AUTHORIZATION_ERRORTOS003Invalid Type
SERVER_ERRORTOS004Invalid Type
1.0.24

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago