b23-lib 1.6.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +439 -1
- package/dist/index.d.ts +439 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Dynamodb/index.ts","../src/Schema/definition.json","../src/Schema/index.ts","../src/Auth/index.ts","../src/enums/ErrorTypes.ts","../src/Logger/index.ts","../node_modules/uuid/dist/esm-node/rng.js","../node_modules/uuid/dist/esm-node/regex.js","../node_modules/uuid/dist/esm-node/validate.js","../node_modules/uuid/dist/esm-node/stringify.js","../node_modules/uuid/dist/esm-node/parse.js","../node_modules/uuid/dist/esm-node/v35.js","../node_modules/uuid/dist/esm-node/native.js","../node_modules/uuid/dist/esm-node/v4.js","../node_modules/uuid/dist/esm-node/sha1.js","../node_modules/uuid/dist/esm-node/v5.js","../src/Utils/index.ts","../src/Utils/response.ts","../src/Utils/fetch.ts"],"sourcesContent":["import {\r\n BatchGetItemCommand,\r\n BatchGetItemCommandInput,\r\n DeleteItemCommand,\r\n DeleteItemCommandInput,\r\n DynamoDBClient,\r\n ExecuteStatementCommand,\r\n ExecuteStatementCommandInput,\r\n GetItemCommand,\r\n GetItemCommandInput,\r\n PutItemCommand,\r\n PutItemCommandInput,\r\n QueryCommand,\r\n QueryCommandInput,\r\n ScanCommand,\r\n ScanCommandInput,\r\n TransactWriteItemsCommand,\r\n TransactWriteItemsCommandInput,\r\n UpdateItemCommand,\r\n UpdateItemCommandInput,\r\n AttributeValue,\r\n ReturnConsumedCapacity,\r\n ReturnValue,\r\n ReturnValuesOnConditionCheckFailure,\r\n ReturnItemCollectionMetrics,\r\n TransactWriteItem,\r\n} from '@aws-sdk/client-dynamodb';\r\n\r\nimport { marshall, unmarshall } from '@aws-sdk/util-dynamodb';\r\n\r\nclass DynamoDBUtility {\r\n private client: DynamoDBClient;\r\n private returnItemCollectionMetrics: ReturnItemCollectionMetrics;\r\n private logCapacity: boolean;\r\n private region: string;\r\n\r\n marshall = marshall;\r\n unmarshall = unmarshall;\r\n ReturnValue = ReturnValue;\r\n ReturnItemCollectionMetrics = ReturnItemCollectionMetrics;\r\n ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure;\r\n\r\n constructor({ region, returnItemCollectionMetrics = ReturnItemCollectionMetrics.NONE, logCapacity = false}: { region: string, returnItemCollectionMetrics: ReturnItemCollectionMetrics, logCapacity: boolean}) {\r\n this.region = region;\r\n this.returnItemCollectionMetrics = returnItemCollectionMetrics;\r\n this.logCapacity = logCapacity;\r\n this.client = new DynamoDBClient({ region: this.region });\r\n }\r\n\r\n private log(message: string, capacity: any, size?: any) {\r\n if (this.logCapacity) {\r\n console.log(message, 'Capacity:', capacity, 'Size:', size);\r\n }\r\n }\r\n\r\n async putItem(\r\n TableName: string,\r\n item: object,\r\n condition: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n ReturnValues: ReturnValue = ReturnValue.NONE,\r\n ReturnValuesOnFailure: ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure.ALL_OLD\r\n ) {\r\n const input: PutItemCommandInput = {\r\n TableName,\r\n Item: marshall(item, {\r\n removeUndefinedValues: true,\r\n convertClassInstanceToMap: true,\r\n }),\r\n ConditionExpression: condition,\r\n ExpressionAttributeNames: attributeName,\r\n ExpressionAttributeValues: attributeValue,\r\n ReturnValues,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnValuesOnConditionCheckFailure: ReturnValuesOnFailure,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new PutItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Put', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n return unmarshall(result.Attributes || {});\r\n }\r\n\r\n async transactWriteItems(transactItems: TransactWriteItem[]) {\r\n const input: TransactWriteItemsCommandInput = {\r\n TransactItems: transactItems.map((item) => {\r\n if (item.Put) {\r\n item.Put.Item = marshall(item.Put.Item, {\r\n removeUndefinedValues: true,\r\n convertClassInstanceToMap: true,\r\n });\r\n }\r\n if (item.Update) {\r\n item.Update.Key = marshall(item.Update.Key);\r\n }\r\n if (item.Delete) {\r\n item.Delete.Key = marshall(item.Delete.Key);\r\n }\r\n return item;\r\n }),\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new TransactWriteItemsCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Transaction', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n }\r\n\r\n async getItem(\r\n TableName: string,\r\n key: object,\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>\r\n ) {\r\n const input: GetItemCommandInput = {\r\n TableName,\r\n Key: marshall(key),\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new GetItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Read', result.ConsumedCapacity);\r\n return unmarshall(result.Item || {});\r\n }\r\n\r\n async batchGetItem(\r\n TableName: string,\r\n keys: object[],\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>\r\n ) {\r\n const input: BatchGetItemCommandInput = {\r\n RequestItems: {\r\n [TableName]: {\r\n Keys: keys.map((key) => marshall(key)),\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n },\r\n },\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new BatchGetItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('BatchRead', result.ConsumedCapacity);\r\n return result.Responses?.[TableName]?.map((item) => unmarshall(item)) || [];\r\n }\r\n\r\n async queryItems(\r\n TableName: string,\r\n keyCondition: string,\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n lastEvaluatedKey?: Record<string, AttributeValue>\r\n ) {\r\n const input: QueryCommandInput = {\r\n TableName,\r\n KeyConditionExpression: keyCondition,\r\n ExpressionAttributeValues: attributeValue,\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ExclusiveStartKey: lastEvaluatedKey,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new QueryCommand(input);\r\n const result = await this.client.send(command);\r\n\r\n this.log('Query', result.ConsumedCapacity);\r\n return {\r\n items: result.Items?.map((item) => unmarshall(item)) || [],\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n\r\n async scanItems(\r\n TableName: string,\r\n filterExpression?: string,\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n lastEvaluatedKey?: Record<string, AttributeValue>\r\n ) {\r\n const input: ScanCommandInput = {\r\n TableName,\r\n FilterExpression: filterExpression,\r\n ExpressionAttributeValues: attributeValue,\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ExclusiveStartKey: lastEvaluatedKey,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new ScanCommand(input);\r\n const result = await this.client.send(command);\r\n\r\n this.log('Scan', result.ConsumedCapacity);\r\n return {\r\n items: result.Items?.map((item) => unmarshall(item)) || [],\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n\r\n async partiQL(\r\n statement: string,\r\n parameter: AttributeValue[] = [],\r\n nextToken?: string,\r\n consistent: boolean = false\r\n ) {\r\n const input: ExecuteStatementCommandInput = {\r\n Statement: statement,\r\n Parameters: parameter,\r\n ConsistentRead: consistent,\r\n NextToken: nextToken,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n };\r\n\r\n const command = new ExecuteStatementCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('PartiQL', result.ConsumedCapacity);\r\n return {\r\n Items: result.Items?.map((item) => unmarshall(item)) || [],\r\n nextToken: result.NextToken,\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n\r\n async updateItem(\r\n TableName: string,\r\n key: object,\r\n condition: string,\r\n update: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n ReturnValues: ReturnValue = ReturnValue.UPDATED_NEW,\r\n ReturnValuesOnFailure: ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure.ALL_OLD\r\n ) {\r\n const input: UpdateItemCommandInput = {\r\n TableName,\r\n Key: marshall(key),\r\n ConditionExpression: condition,\r\n UpdateExpression: update,\r\n ExpressionAttributeNames: attributeName,\r\n ExpressionAttributeValues: attributeValue,\r\n ReturnValues,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnValuesOnConditionCheckFailure: ReturnValuesOnFailure,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new UpdateItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Update', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n return unmarshall(result.Attributes || {});\r\n }\r\n\r\n async deleteItem(\r\n TableName: string,\r\n key: object,\r\n condition: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n ReturnValues: ReturnValue = ReturnValue.ALL_OLD,\r\n ReturnValuesOnFailure: ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure.ALL_OLD\r\n ) {\r\n const input: DeleteItemCommandInput = {\r\n TableName,\r\n Key: marshall(key),\r\n ConditionExpression: condition,\r\n ExpressionAttributeNames: attributeName,\r\n ExpressionAttributeValues: attributeValue,\r\n ReturnValues,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnValuesOnConditionCheckFailure: ReturnValuesOnFailure,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new DeleteItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Delete', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n return unmarshall(result.Attributes || {});\r\n }\r\n\r\n async getItemByIndex(\r\n TableName: string, \r\n index: string, \r\n keyCondition: string, \r\n consistent: boolean = false, \r\n projection?: string, \r\n attributeName?: Record<string, string>, \r\n attributeValue?: Record<string, AttributeValue>,\r\n lastEvaluatedKey?: Record<string, AttributeValue>\r\n ) {\r\n const input: QueryCommandInput = {\r\n TableName,\r\n IndexName: index,\r\n KeyConditionExpression: keyCondition,\r\n ExpressionAttributeValues: attributeValue,\r\n ExclusiveStartKey: lastEvaluatedKey,\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES\r\n }\r\n \r\n const command = new QueryCommand(input);\r\n const result = await this.client.send(command);\r\n this.log(\"GetItemByIndex\", result.ConsumedCapacity);\r\n return { \r\n Items: result.Items?.map(item => unmarshall(item)) || [],\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n}\r\n\r\nexport default DynamoDBUtility;\r\n","{\r\n \"$id\": \"standards\",\r\n \"definitions\": {\r\n \"lowercaseText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]*$\"\r\n },\r\n \"lowercaseText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,10}$\"\r\n },\r\n \"lowercaseText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,16}$\"\r\n },\r\n \"lowercaseText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,30}$\"\r\n },\r\n \"lowercaseText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,50}$\"\r\n },\r\n \"lowercaseText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,256}$\"\r\n },\r\n \"text\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).*$\"\r\n },\r\n \"text10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,10}$\"\r\n },\r\n \"text16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,16}$\"\r\n },\r\n \"text30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,30}$\"\r\n },\r\n \"text50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,50}$\"\r\n },\r\n \"text256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,256}$\"\r\n },\r\n \"requiredText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).+$\"\r\n },\r\n \"requiredText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,10}$\"\r\n },\r\n \"requiredText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,16}$\"\r\n },\r\n \"requiredText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,30}$\"\r\n },\r\n \"requiredText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,50}$\"\r\n },\r\n \"requiredText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,256}$\"\r\n },\r\n \"url\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^https://[^\\\\s/$.?#].[^\\\\s]*$\",\r\n \"maxLength\": 2048\r\n },\r\n \"uuid\": {\r\n \"type\": \"string\",\r\n \"minLength\": 1,\r\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"\r\n },\r\n \"productKey\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"variantId\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\r\n \"phone\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[0-9]{10}$\"\r\n },\r\n \"email\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[^\\\\s]+@[^\\\\s]+\\\\.[^\\\\s]+$\"\r\n },\r\n \"addressLine1\": { \"$ref\": \"#/definitions/requiredText50\" },\r\n \"addressLine2\": { \"$ref\": \"#/definitions/text50\" },\r\n \"city\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"postalCode\": { \"$ref\": \"#/definitions/requiredText16\" },\r\n \"state\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"AP\", \"AR\", \"AS\", \"BR\", \"CT\", \"GA\", \"GJ\", \"HR\", \"HP\", \"JH\", \"KA\", \"KL\", \"MP\", \"MH\", \"MN\", \"ML\", \"MZ\", \"NL\", \"OR\", \"PB\", \"RJ\", \"SK\", \"TN\", \"TG\", \"TR\", \"UP\", \"UT\", \"WB\", \"AN\", \"CH\", \"DH\", \"LD\", \"DL\", \"PY\", \"LA\", \"JK\"]\r\n },\r\n \"country\": {\r\n \"type\": \"string\",\r\n \"enum\": [\r\n \"IN\"\r\n ]\r\n },\r\n \"currency\": {\r\n \"type\": \"string\",\r\n \"enum\": [\r\n \"INR\"\r\n ]\r\n },\r\n \"locale\": {\r\n \"type\": \"string\",\r\n \"enum\": [\r\n \"en-IN\"\r\n ]\r\n },\r\n \"addressType\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"shipping\", \"billing\", \"shipping&billing\"]\r\n },\r\n \"address\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"firstName\": {\"$ref\": \"standards#/definitions/firstName\"},\r\n \"lastName\": { \"$ref\": \"standards#/definitions/lastName\" },\r\n \"phone\": { \"$ref\": \"standards#/definitions/phone\" },\r\n \"email\": { \"$ref\": \"standards#/definitions/email\" },\r\n \"addressLine1\": { \"$ref\": \"standards#/definitions/addressLine1\" },\r\n \"addressLine2\": { \"$ref\": \"standards#/definitions/addressLine2\" },\r\n \"city\": { \"$ref\": \"standards#/definitions/city\" },\r\n \"postalCode\": { \"$ref\": \"standards#/definitions/postalCode\" },\r\n \"state\": { \"$ref\": \"standards#/definitions/state\" },\r\n \"country\": { \"$ref\": \"standards#/definitions/country\" }\r\n },\r\n \"required\": [\"firstName\", \"lastName\", \"phone\", \"email\", \"addressLine1\", \"postalCode\", \"state\", \"country\"]\r\n }\r\n }\r\n}","import SchemaDefinitions from './definition.json';\r\n\r\nconst Schema = {\r\n getStandardSchemaDefinition() {\r\n return SchemaDefinitions;\r\n }\r\n}\r\n\r\nexport default Schema;\r\n","import { importPKCS8, importSPKI, jwtVerify, SignJWT} from 'jose';\r\nimport ErrorTypes from '../enums/ErrorTypes';\r\nimport Logger from '../Logger';\r\nimport Utils from '../Utils';\r\nimport ResponseUtility from '../Utils/response';\r\nimport assert from 'assert';\r\nimport Fetch from '../Utils/fetch';\r\n\r\ntype StringifiedJSONArray = string;\r\n\r\nexport interface AuthUtilityConfig {\r\n maxTokenAge: string;\r\n userPrivateKeys: StringifiedJSONArray;\r\n userPublicKeys: StringifiedJSONArray;\r\n anonymousPrivateKeys: StringifiedJSONArray;\r\n anonymousPublicKeys: StringifiedJSONArray;\r\n systemPrivateKeys: StringifiedJSONArray;\r\n systemPublicKeys: StringifiedJSONArray;\r\n adminPrivateKeys: StringifiedJSONArray;\r\n adminPublicKeys: StringifiedJSONArray;\r\n}\r\n\r\nexport const DefaultAuthUtilityConfig: Readonly<AuthUtilityConfig> = {\r\n maxTokenAge: '30 days',\r\n userPrivateKeys: '[]',\r\n userPublicKeys: '[]',\r\n anonymousPrivateKeys: '[]',\r\n anonymousPublicKeys: '[]',\r\n systemPrivateKeys: '[]',\r\n systemPublicKeys: '[]',\r\n adminPrivateKeys: '[]',\r\n adminPublicKeys: '[]',\r\n};\r\n\r\nexport type AuthTokenType = 'Anon' | 'User' | 'System' | 'Admin' | 'CDN';\r\n\r\nexport interface AuthMiddlewareConfig {\r\n allowAnonymous: boolean;\r\n allowSystem: boolean;\r\n allowUser: boolean;\r\n allowCDN: boolean;\r\n}\r\n\r\nexport const DefaultAuthMiddlewareConfig: Readonly<AuthMiddlewareConfig> = {\r\n allowAnonymous: false,\r\n allowSystem: true,\r\n allowUser: true,\r\n allowCDN: false\r\n};\r\n\r\n/**\r\n * A utility class for JWT authentication and authorization.\r\n */\r\nclass AuthUtility {\r\n private maxTokenAge: string;\r\n private userPrivateKeys: string[];\r\n private userPublicKeys: string[];\r\n private anonymousPrivateKeys: string[];\r\n private anonymousPublicKeys: string[];\r\n private systemPrivateKeys: string[];\r\n private systemPublicKeys: string[];\r\n private adminPrivateKeys: string[];\r\n private adminPublicKeys: string[];\r\n\r\n /**\r\n * Initializes the AuthUtility class with a configuration.\r\n * @param config The configuration for the utility (optional).\r\n */\r\n constructor(config: Partial<AuthUtilityConfig> = DefaultAuthUtilityConfig) {\r\n const {\r\n maxTokenAge,\r\n userPrivateKeys,\r\n userPublicKeys,\r\n anonymousPrivateKeys,\r\n anonymousPublicKeys,\r\n systemPrivateKeys,\r\n systemPublicKeys,\r\n adminPrivateKeys,\r\n adminPublicKeys,\r\n } = { ...DefaultAuthUtilityConfig, ...config };\r\n\r\n this.maxTokenAge = maxTokenAge;\r\n\r\n this.userPrivateKeys = JSON.parse(userPrivateKeys);\r\n this.userPublicKeys = JSON.parse(userPublicKeys);\r\n\r\n this.anonymousPrivateKeys = JSON.parse(anonymousPrivateKeys);\r\n this.anonymousPublicKeys = JSON.parse(anonymousPublicKeys);\r\n\r\n this.systemPrivateKeys = JSON.parse(systemPrivateKeys);\r\n this.systemPublicKeys = JSON.parse(systemPublicKeys);\r\n\r\n this.adminPrivateKeys = JSON.parse(adminPrivateKeys);\r\n this.adminPublicKeys = JSON.parse(adminPublicKeys);\r\n\r\n this.logWarnings();\r\n }\r\n\r\n /**\r\n * Logs warnings if the number of keys exceeds recommended limits.\r\n */\r\n private logWarnings() {\r\n const warn = (type: string, keys: string[], limit: number) =>\r\n keys.length > limit &&\r\n Logger.logWarning(\r\n 'AuthUtility',\r\n `More than ${limit} ${type} keys provided. This is not recommended.`\r\n );\r\n\r\n warn('user private', this.userPrivateKeys, 3);\r\n warn('user public', this.userPublicKeys, 3);\r\n warn('anonymous private', this.anonymousPrivateKeys, 1);\r\n warn('anonymous public', this.anonymousPublicKeys, 3);\r\n warn('system private', this.systemPrivateKeys, 1);\r\n warn('system public', this.systemPublicKeys, 3);\r\n warn('admin private', this.adminPrivateKeys, 1);\r\n warn('admin public', this.adminPublicKeys, 3);\r\n }\r\n\r\n private async createSignedJWT(payload: any, privateKeyString: string, expiration: string){\r\n const privateKey = await importPKCS8(privateKeyString, 'RS256');\r\n const token = await new SignJWT(payload)\r\n .setProtectedHeader({ alg: 'RS256' })\r\n .setExpirationTime(expiration)\r\n .setIssuedAt()\r\n .sign(privateKey);\r\n\r\n return token;\r\n }\r\n\r\n private async verifySignedJWT(token: string, publicKeyString: string[], expiration: string){\r\n for(let i = publicKeyString.length - 1; i > 0 ; i--){\r\n try { \r\n const publicKey = await importSPKI(publicKeyString[i], 'RS256')\r\n const jwt = await jwtVerify(token, publicKey, { clockTolerance: 30, maxTokenAge: expiration });\r\n return jwt.payload;\r\n } catch (error) {\r\n // Try with the next oldest key\r\n continue;\r\n }\r\n }\r\n\r\n const publicKey = await importSPKI(publicKeyString[0], 'RS256')\r\n const jwt = await jwtVerify(token, publicKey, { clockTolerance: 30, maxTokenAge: expiration });\r\n return jwt.payload;\r\n }\r\n\r\n \r\n /**\r\n * Creates an anonymous token with the given ID and additional data.\r\n *\r\n * @param id - The unique identifier for the token. Must be a valid UUID.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT as a string.\r\n * @throws Will throw an error if no anonymous private keys are found or if the ID is not a valid UUID.\r\n */\r\n async createAnonymousToken(id: string, additionalData?: object): Promise<string> {\r\n assert(this.anonymousPrivateKeys.length, ErrorTypes.ANONYMOUS_PRIVATE_KEY_NOT_FOUND);\r\n\r\n assert(Utils.isUUID(id), ErrorTypes.INVALID_UUID);\r\n const payload = {\r\n id,\r\n type: 'Anon',\r\n ...additionalData\r\n };\r\n\r\n return await this.createSignedJWT(payload, this.anonymousPrivateKeys[this.anonymousPrivateKeys.length - 1], this.maxTokenAge);\r\n }\r\n\r\n /**\r\n * Verifies an anonymous token by checking its signature and payload type.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @returns The payload of the verified token.\r\n * @throws Will throw an error if no anonymous public keys are found or if the token type is invalid.\r\n */\r\n async verifyAnonymousToken(token: string){\r\n assert(this.anonymousPublicKeys.length, ErrorTypes.ANONYMOUS_PUBLIC_KEY_NOT_FOUND);\r\n const payload = await this.verifySignedJWT(token, this.anonymousPublicKeys, this.maxTokenAge);\r\n assert(payload.type === 'Anon', ErrorTypes.INVALID_AUTH_TYPE);\r\n return payload;\r\n }\r\n\r\n /**\r\n * Creates a signed JWT token for a user.\r\n *\r\n * @param id - The UUID of the user.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT token as a string.\r\n * @throws Will throw an error if no user private keys are found or if the provided id is not a valid UUID.\r\n */\r\n async createUserToken(id: string, additionalData?: object): Promise<string> {\r\n assert(this.userPrivateKeys.length, ErrorTypes.USER_PRIVATE_KEY_NOT_FOUND);\r\n assert(Utils.isUUID(id), ErrorTypes.INVALID_UUID);\r\n\r\n const payload = {\r\n id,\r\n type: 'User',\r\n ...additionalData\r\n };\r\n return await this.createSignedJWT(payload, this.userPrivateKeys[this.userPrivateKeys.length - 1], this.maxTokenAge);\r\n }\r\n\r\n /**\r\n * Verifies the provided user token by checking its signature and payload.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @returns The payload of the verified token if valid.\r\n * @throws Will throw an error if no user public keys are found or if the token type is invalid.\r\n */\r\n async verifyUserToken(token: string){\r\n assert(this.userPublicKeys.length, ErrorTypes.USER_PUBLIC_KEY_NOT_FOUND);\r\n const payload =await this.verifySignedJWT(token, this.userPublicKeys, this.maxTokenAge);\r\n assert(payload.type === 'User', ErrorTypes.INVALID_AUTH_TYPE);\r\n return payload;\r\n }\r\n\r\n /**\r\n * Creates a signed JWT (JSON Web Token) for a system with the given ID and optional additional data.\r\n *\r\n * @param id - The unique identifier for the system.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT as a string.\r\n * @throws Will throw an error if no system private keys are found.\r\n */\r\n async createSystemToken(id: string, additionalData?: object): Promise<string> {\r\n assert(this.systemPrivateKeys.length, ErrorTypes.SYSTEM_PRIVATE_KEY_NOT_FOUND);\r\n\r\n const payload = {\r\n id,\r\n type: 'System',\r\n ...additionalData\r\n };\r\n return await this.createSignedJWT(payload, this.systemPrivateKeys[this.systemPrivateKeys.length - 1], '5 min');\r\n }\r\n\r\n /**\r\n * Verifies a system token by checking its signature and payload type.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @returns The payload of the verified token.\r\n * @throws Will throw an error if no system public keys are found or if the token type is not 'System'.\r\n */\r\n async verifySystemToken(token: string){\r\n assert(this.systemPublicKeys.length, ErrorTypes.USER_PUBLIC_KEY_NOT_FOUND);\r\n const payload = await this.verifySignedJWT(token, this.systemPublicKeys, '5 min');\r\n assert(payload.type === 'System', ErrorTypes.INVALID_AUTH_TYPE);\r\n return payload;\r\n }\r\n\r\n /**\r\n * Creates a signed JWT token for an admin user.\r\n *\r\n * @param email - The email of the admin user.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT token string.\r\n * @throws Will throw an error if no admin private keys are found or if the provided id is not a valid UUID.\r\n */\r\n async createAdminToken(email: string, verifier: string, additionalData?: object): Promise<string> {\r\n assert(this.adminPrivateKeys.length, ErrorTypes.ADMIN_PRIVATE_KEY_NOT_FOUND);\r\n\r\n assert(Utils.isEmail(email), ErrorTypes.INVALID_EMAIL);\r\n assert(Utils.isURL(verifier), ErrorTypes.INVALID_VERIFIER);\r\n const payload = {\r\n email,\r\n type: 'Admin',\r\n verifier: verifier,\r\n ...additionalData\r\n };\r\n return await this.createSignedJWT(payload, this.adminPrivateKeys[this.adminPrivateKeys.length - 1], this.maxTokenAge);\r\n }\r\n\r\n /**\r\n * Verifies the provided admin token by checking its signature and payload.\r\n * Ensures that the token is signed with one of the known admin public keys\r\n * and that the payload type is 'Admin'.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @param permissions - The permissions required for the admin user.\r\n * @param authenticate - Whether to authenticate the token with the verifier.\r\n * @returns The payload of the verified token.\r\n * @throws Will throw an error if no admin public keys are found or if the token is invalid or if the admin doesn't have proper permissions.\r\n */\r\n async verifyAdminToken(token: string, permissions: string[], authenticate: boolean){\r\n assert(this.adminPublicKeys.length, ErrorTypes.ADMIN_PUBLIC_KEY_NOT_FOUND);\r\n const payload = await this.verifySignedJWT(token, this.adminPublicKeys, this.maxTokenAge);\r\n assert(payload.type === 'Admin', ErrorTypes.INVALID_AUTH_TYPE);\r\n\r\n if(authenticate) {\r\n const response = await Fetch(payload.verifier as string, '', 'POST', {}, { token, permissions });\r\n assert(response.data.isTokenValid === true, ErrorTypes.INVALID_TOKEN);\r\n \r\n if(response.data.hasPermissions !== true){\r\n throw ResponseUtility.generateError(403, ErrorTypes.INVALID_PERMISSIONS)\r\n }\r\n }\r\n\r\n return payload;\r\n }\r\n\r\n /**\r\n * Middleware function to handle authentication based on different token types.\r\n * It verifies the token and sets the authentication details in the response locals.\r\n *\r\n * @param {Partial<AuthMiddlewareConfig>} [config=DefaultAuthMiddlewareConfig] - Configuration object to customize the middleware behavior.\r\n * @returns Middleware function to handle authentication.\r\n */\r\n AuthMiddleware(config: Partial<AuthMiddlewareConfig> = DefaultAuthMiddlewareConfig, permissions: string[] = []) {\r\n const { allowAnonymous, allowSystem, allowUser, allowCDN } = { ...DefaultAuthMiddlewareConfig, ...config };\r\n return async (req: any, res: any, next: any) => {\r\n try {\r\n const [authType, token] = req.get('Authorization')?.split(' ') || [];\r\n if (!token) throw new Error(ErrorTypes.INVALID_TOKEN);\r\n\r\n let payload;\r\n switch (authType as AuthTokenType) {\r\n case 'Anon':\r\n if (!allowAnonymous) throw ResponseUtility.generateError(403, ErrorTypes.ANONYMOUS_SESSION_NOT_ALLOWED);\r\n payload = await this.verifyAnonymousToken(token);\r\n break;\r\n case 'User':\r\n if (!allowUser) throw ResponseUtility.generateError(403, ErrorTypes.USER_SESSION_NOT_ALLOWED);\r\n payload = await this.verifyUserToken(token);\r\n break;\r\n case 'System':\r\n if (!allowSystem) throw ResponseUtility.generateError(403, ErrorTypes.SYSTEM_SESSION_NOT_ALLOWED);\r\n payload = await this.verifySystemToken(token);\r\n Logger.logMessage('AuthMiddleware', `System Name - ${payload.id}`);\r\n break;\r\n case 'Admin':\r\n payload = await this.verifyAdminToken(token, permissions, true);\r\n Logger.logMessage('AuthMiddleware', `Admin - ${payload.email}`);\r\n break;\r\n case 'CDN':\r\n if (!allowCDN) throw ResponseUtility.generateError(403, ErrorTypes.CDN_SESSION_NOT_ALLOWED);\r\n assert(['E3CQMOP5FX6KD1', 'E3TNCKKZ3FOX9W'].includes(token), ErrorTypes.INVALID_TOKEN);\r\n Logger.logMessage('AuthMiddleware', `CDN DistributionId - ${token}`);\r\n break;\r\n default:\r\n throw ResponseUtility.generateError(403, ErrorTypes.INVALID_AUTH_TYPE);\r\n }\r\n\r\n res.locals.auth = { authType, token, ...payload };\r\n next();\r\n } catch (error: any) {\r\n Logger.logError('AuthMiddleware', error);\r\n ResponseUtility.handleException(\r\n 'AuthMiddleware',\r\n ResponseUtility.generateError(401, error.error || ErrorTypes.TOKEN_EXPIRED, true),\r\n res\r\n );\r\n }\r\n };\r\n }\r\n}\r\n\r\nexport default AuthUtility;\r\n\r\n","export default Object.freeze({\r\n INVALID_UUID: \"Invalid UUID\",\r\n INVALID_EMAIL: \"Invalid Email\",\r\n INVALID_TOKEN: \"Invalid Token\",\r\n TOKEN_EXPIRED: \"Token Expired\",\r\n INVALID_VERIFIER: \"Invalid Verifier\",\r\n INVALID_PERMISSIONS: \"Invalid Permissions\",\r\n INVALID_AUTH_TYPE: \"Invalid Authorization Type\",\r\n USER_PRIVATE_KEY_NOT_FOUND: \"User Private Key Not Found\",\r\n USER_PUBLIC_KEY_NOT_FOUND: \"User Public Key Not Found\",\r\n ANONYMOUS_PRIVATE_KEY_NOT_FOUND: \"Anonymous Private Key Not Found\",\r\n ANONYMOUS_PUBLIC_KEY_NOT_FOUND: \"Anonymous Public Key Not Found\",\r\n SYSTEM_PRIVATE_KEY_NOT_FOUND: \"System Private Key Not Found\",\r\n SYSTEM_PUBLIC_KEY_NOT_FOUND: \"System Public Key Not Found\",\r\n ADMIN_PRIVATE_KEY_NOT_FOUND: \"Admin Private Key Not Found\",\r\n ADMIN_PUBLIC_KEY_NOT_FOUND: \"Admin Public Key Not Found\",\r\n SECRET_TOKEN_NOT_FOUND: \"Secret Token Not Found\",\r\n ANONYMOUS_SESSION_NOT_ALLOWED: \"Anonymous Session Not Allowed\",\r\n USER_SESSION_NOT_ALLOWED: \"User Session Not Allowed\",\r\n SYSTEM_SESSION_NOT_ALLOWED: \"System Session Not Allowed\",\r\n CDN_SESSION_NOT_ALLOWED: \"CDN Session Not Allowed\",\r\n INTERNAL_SERVER_ERROR: \"Internal Server Error\",\r\n SOMETHING_WENT_WRONG: 'Something went wrong'\r\n})","import util from 'node:util';\r\nconst Logger = {\r\n logException: (functionName: string, error: any) => {\r\n console.error(`Exception Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logError: (functionName: string, error: any) => {\r\n console.error(`Error Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logWarning: (functionName: string, message: any) => {\r\n console.warn(`Warning in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logMessage: (functionName: string, message: any) => {\r\n console.log(`Message in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logInvalidPayload: (functionName: string, errorMessage: string) => {\r\n console.error(`Invalid Payload received for Function: ${functionName}, Error: ${Logger.inspect(errorMessage)}`);\r\n },\r\n\r\n inspect: (context: any) => {\r\n return (typeof context === \"string\" ? context : util.inspect(context));\r\n }\r\n}\r\n\r\nexport default Logger;","import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, variantId: string) => {\r\n return `${key}#${variantId}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, variantId] = searchId.split('#');\r\n return {\r\n key,\r\n variantId\r\n }\r\n },\r\n}\r\n\r\nexport default Utils;\r\n","import ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport const ResponseUtility = {\r\n handleException: (functionName: string, error: any, res: any) => {\r\n if (error.knownError) {\r\n error.logError && Logger.logError(functionName, error);\r\n res.status(error.status).json({\r\n status: error.status,\r\n error: error.error\r\n });\r\n } else if(error.status && error.error) {\r\n Logger.logException(functionName, error);\r\n res.status(error.status).json({\r\n ...error.error,\r\n status: error.status,\r\n });\r\n } else {\r\n Logger.logException(functionName, error);\r\n res.status(500).json({\r\n status: 500,\r\n error: ErrorTypes.INTERNAL_SERVER_ERROR\r\n })\r\n }\r\n },\r\n\r\n generateResponse: (status: number, data?: any, error?: string) => {\r\n return {\r\n status,\r\n data,\r\n error\r\n }\r\n },\r\n\r\n generateError: (status: number, error: string, knownError: Boolean = true, logError: boolean = false) => {\r\n return {\r\n status,\r\n error,\r\n knownError,\r\n logError\r\n }\r\n }\r\n}\r\n\r\nexport default ResponseUtility;","\"use client\";\r\n\r\nimport ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport type ErrorType = {\r\n status: number;\r\n statusText: string;\r\n error: any;\r\n};\r\n\r\nexport type SuccessType = {\r\n status: number;\r\n statusText: string;\r\n data: any;\r\n};\r\n\r\n/**\r\n * Makes an HTTP request to the specified endpoint using the provided parameters.\r\n *\r\n * @param {string} baseURL - The base URL of the API.\r\n * @param {string} endpoint - The specific endpoint to call.\r\n * @param {'GET' | 'POST' | 'PATCH' | 'DELETE'} [method='GET'] - The HTTP method to use for the request.\r\n * @param {Record<string, string>} [headers={}] - Additional headers to include in the request.\r\n * @param {any} [payload] - The payload to send with the request, if applicable.\r\n * @returns {Promise<SuccessType>} - A promise that resolves to the response data if the request is successful.\r\n * @throws {ErrorType} - Throws an error if the request fails.\r\n */\r\nconst Fetch = async (\r\n baseURL: string,\r\n endpoint: string,\r\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET',\r\n headers: Record<string, string> = {},\r\n payload?: any,\r\n): Promise<SuccessType> => {\r\n const options: RequestInit = {\r\n method,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n ...headers,\r\n },\r\n };\r\n\r\n if (method !== 'GET' && payload) {\r\n options.body = JSON.stringify(payload);\r\n }\r\n\r\n const completeURL = `${baseURL}${endpoint ? ('/' + endpoint) : ''}`\r\n try {\r\n const response: any = await fetch(completeURL, options);\r\n\r\n if (!response.ok) {\r\n const errorBody: any = await response.json().catch(() => response.text());\r\n\r\n throw {\r\n status: response.status,\r\n statusText: response.statusText,\r\n error: errorBody ? errorBody : {\r\n status: response.status,\r\n error: response.statusText,\r\n }\r\n } as ErrorType;\r\n }\r\n\r\n const body = await response.json();\r\n\r\n Logger.logMessage('Fetch', `API call successful: URL-${completeURL}, Status- ${response.status}`);\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n data: body.data,\r\n } as SuccessType;\r\n } catch (err: any) {\r\n \r\n Logger.logError('Fetch', `API call failed: URL-${completeURL}, Status- ${err.status || 500}, Error- ${Logger.inspect(err.error || err)}`);\r\n throw {\r\n status: err.status || 500,\r\n statusText: err.statusText || ErrorTypes.INTERNAL_SERVER_ERROR,\r\n error: err.error || {\r\n status: err.status || 500,\r\n error: err.statusText || ErrorTypes.SOMETHING_WENT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8B,EAAK,CACP,OAASE,EAAY,CACnBjC,EAAO,SAAS,iBAAkBiC,CAAK,EACvCT,EAAgB,gBACd,iBACAA,EAAgB,cAAc,IAAKS,EAAM,OAASjB,EAAW,cAAe,EAAI,EAChFc,CACF,CACF,CACF,CACF,CACF,EAEOI,GAAQjD","names":["BatchGetItemCommand","DeleteItemCommand","DynamoDBClient","ExecuteStatementCommand","GetItemCommand","PutItemCommand","QueryCommand","ScanCommand","TransactWriteItemsCommand","UpdateItemCommand","ReturnConsumedCapacity","ReturnValue","ReturnValuesOnConditionCheckFailure","ReturnItemCollectionMetrics","marshall","unmarshall","DynamoDBUtility","region","returnItemCollectionMetrics","logCapacity","message","capacity","size","TableName","item","condition","attributeName","attributeValue","ReturnValues","ReturnValuesOnFailure","input","command","result","transactItems","key","consistent","projection","keys","keyCondition","lastEvaluatedKey","filterExpression","statement","parameter","nextToken","update","index","Dynamodb_default","definition_default","Schema","definition_default","Schema_default","importPKCS8","importSPKI","jwtVerify","SignJWT","ErrorTypes_default","util","Logger","functionName","error","message","errorMessage","context","Logger_default","crypto","rnds8Pool","poolPtr","rng","regex_default","validate","uuid","regex_default","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","uuid","validate_default","v","arr","parse_default","stringToBytes","str","bytes","i","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","offset","_namespace","parse_default","unsafeStringify","crypto","native_default","v4","options","buf","offset","native_default","rnds","rng","i","unsafeStringify","v4_default","crypto","sha1","bytes","sha1_default","v5","v35","sha1_default","v5_default","Utils","value","namespace","v5_default","v4_default","key","variantId","searchId","Utils_default","ResponseUtility","functionName","error","res","Logger_default","ErrorTypes_default","status","data","knownError","logError","response_default","assert","Fetch","baseURL","endpoint","method","headers","payload","options","completeURL","response","errorBody","body","Logger_default","err","ErrorTypes_default","fetch_default","DefaultAuthUtilityConfig","DefaultAuthMiddlewareConfig","AuthUtility","config","maxTokenAge","userPrivateKeys","userPublicKeys","anonymousPrivateKeys","anonymousPublicKeys","systemPrivateKeys","systemPublicKeys","adminPrivateKeys","adminPublicKeys","warn","type","keys","limit","Logger_default","payload","privateKeyString","expiration","privateKey","importPKCS8","SignJWT","token","publicKeyString","i","publicKey","importSPKI","jwtVerify","id","additionalData","assert","ErrorTypes_default","Utils_default","email","verifier","permissions","authenticate","response","fetch_default","response_default","allowAnonymous","allowSystem","allowUser","allowCDN","req","res","next","authType","error","Auth_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/Dynamodb/index.ts","../src/Schema/definition.json","../src/Schema/index.ts","../src/Auth/index.ts","../src/enums/ErrorTypes.ts","../src/Logger/index.ts","../node_modules/uuid/dist/esm-node/rng.js","../node_modules/uuid/dist/esm-node/regex.js","../node_modules/uuid/dist/esm-node/validate.js","../node_modules/uuid/dist/esm-node/stringify.js","../node_modules/uuid/dist/esm-node/parse.js","../node_modules/uuid/dist/esm-node/v35.js","../node_modules/uuid/dist/esm-node/native.js","../node_modules/uuid/dist/esm-node/v4.js","../node_modules/uuid/dist/esm-node/sha1.js","../node_modules/uuid/dist/esm-node/v5.js","../src/Utils/index.ts","../src/Utils/response.ts","../src/Utils/fetch.ts","../src/Classes/Address.ts","../src/Classes/ImageInfo.ts","../src/Classes/Enum.ts","../src/Classes/Price.ts","../src/Classes/Coupon.ts","../src/Classes/Cart.ts","../src/Classes/Customer.ts","../src/Classes/Order.ts","../src/Classes/Payment.ts"],"sourcesContent":["import {\r\n BatchGetItemCommand,\r\n BatchGetItemCommandInput,\r\n DeleteItemCommand,\r\n DeleteItemCommandInput,\r\n DynamoDBClient,\r\n ExecuteStatementCommand,\r\n ExecuteStatementCommandInput,\r\n GetItemCommand,\r\n GetItemCommandInput,\r\n PutItemCommand,\r\n PutItemCommandInput,\r\n QueryCommand,\r\n QueryCommandInput,\r\n ScanCommand,\r\n ScanCommandInput,\r\n TransactWriteItemsCommand,\r\n TransactWriteItemsCommandInput,\r\n UpdateItemCommand,\r\n UpdateItemCommandInput,\r\n AttributeValue,\r\n ReturnConsumedCapacity,\r\n ReturnValue,\r\n ReturnValuesOnConditionCheckFailure,\r\n ReturnItemCollectionMetrics,\r\n TransactWriteItem,\r\n} from '@aws-sdk/client-dynamodb';\r\n\r\nimport { marshall, unmarshall } from '@aws-sdk/util-dynamodb';\r\n\r\nclass DynamoDBUtility {\r\n private client: DynamoDBClient;\r\n private returnItemCollectionMetrics: ReturnItemCollectionMetrics;\r\n private logCapacity: boolean;\r\n private region: string;\r\n\r\n marshall = marshall;\r\n unmarshall = unmarshall;\r\n ReturnValue = ReturnValue;\r\n ReturnItemCollectionMetrics = ReturnItemCollectionMetrics;\r\n ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure;\r\n\r\n constructor({ region, returnItemCollectionMetrics = ReturnItemCollectionMetrics.NONE, logCapacity = false}: { region: string, returnItemCollectionMetrics: ReturnItemCollectionMetrics, logCapacity: boolean}) {\r\n this.region = region;\r\n this.returnItemCollectionMetrics = returnItemCollectionMetrics;\r\n this.logCapacity = logCapacity;\r\n this.client = new DynamoDBClient({ region: this.region });\r\n }\r\n\r\n private log(message: string, capacity: any, size?: any) {\r\n if (this.logCapacity) {\r\n console.log(message, 'Capacity:', capacity, 'Size:', size);\r\n }\r\n }\r\n\r\n async putItem(\r\n TableName: string,\r\n item: object,\r\n condition: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n ReturnValues: ReturnValue = ReturnValue.NONE,\r\n ReturnValuesOnFailure: ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure.ALL_OLD\r\n ) {\r\n const input: PutItemCommandInput = {\r\n TableName,\r\n Item: marshall(item, {\r\n removeUndefinedValues: true,\r\n convertClassInstanceToMap: true,\r\n }),\r\n ConditionExpression: condition,\r\n ExpressionAttributeNames: attributeName,\r\n ExpressionAttributeValues: attributeValue,\r\n ReturnValues,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnValuesOnConditionCheckFailure: ReturnValuesOnFailure,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new PutItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Put', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n return unmarshall(result.Attributes || {});\r\n }\r\n\r\n async transactWriteItems(transactItems: TransactWriteItem[]) {\r\n const input: TransactWriteItemsCommandInput = {\r\n TransactItems: transactItems.map((item) => {\r\n if (item.Put) {\r\n item.Put.Item = marshall(item.Put.Item, {\r\n removeUndefinedValues: true,\r\n convertClassInstanceToMap: true,\r\n });\r\n }\r\n if (item.Update) {\r\n item.Update.Key = marshall(item.Update.Key);\r\n }\r\n if (item.Delete) {\r\n item.Delete.Key = marshall(item.Delete.Key);\r\n }\r\n return item;\r\n }),\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new TransactWriteItemsCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Transaction', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n }\r\n\r\n async getItem(\r\n TableName: string,\r\n key: object,\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>\r\n ) {\r\n const input: GetItemCommandInput = {\r\n TableName,\r\n Key: marshall(key),\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new GetItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Read', result.ConsumedCapacity);\r\n return unmarshall(result.Item || {});\r\n }\r\n\r\n async batchGetItem(\r\n TableName: string,\r\n keys: object[],\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>\r\n ) {\r\n const input: BatchGetItemCommandInput = {\r\n RequestItems: {\r\n [TableName]: {\r\n Keys: keys.map((key) => marshall(key)),\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n },\r\n },\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new BatchGetItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('BatchRead', result.ConsumedCapacity);\r\n return result.Responses?.[TableName]?.map((item) => unmarshall(item)) || [];\r\n }\r\n\r\n async queryItems(\r\n TableName: string,\r\n keyCondition: string,\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n lastEvaluatedKey?: Record<string, AttributeValue>\r\n ) {\r\n const input: QueryCommandInput = {\r\n TableName,\r\n KeyConditionExpression: keyCondition,\r\n ExpressionAttributeValues: attributeValue,\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ExclusiveStartKey: lastEvaluatedKey,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new QueryCommand(input);\r\n const result = await this.client.send(command);\r\n\r\n this.log('Query', result.ConsumedCapacity);\r\n return {\r\n items: result.Items?.map((item) => unmarshall(item)) || [],\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n\r\n async scanItems(\r\n TableName: string,\r\n filterExpression?: string,\r\n consistent: boolean = false,\r\n projection?: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n lastEvaluatedKey?: Record<string, AttributeValue>\r\n ) {\r\n const input: ScanCommandInput = {\r\n TableName,\r\n FilterExpression: filterExpression,\r\n ExpressionAttributeValues: attributeValue,\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ExclusiveStartKey: lastEvaluatedKey,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.TOTAL,\r\n };\r\n\r\n const command = new ScanCommand(input);\r\n const result = await this.client.send(command);\r\n\r\n this.log('Scan', result.ConsumedCapacity);\r\n return {\r\n items: result.Items?.map((item) => unmarshall(item)) || [],\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n\r\n async partiQL(\r\n statement: string,\r\n parameter: AttributeValue[] = [],\r\n nextToken?: string,\r\n consistent: boolean = false\r\n ) {\r\n const input: ExecuteStatementCommandInput = {\r\n Statement: statement,\r\n Parameters: parameter,\r\n ConsistentRead: consistent,\r\n NextToken: nextToken,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n };\r\n\r\n const command = new ExecuteStatementCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('PartiQL', result.ConsumedCapacity);\r\n return {\r\n Items: result.Items?.map((item) => unmarshall(item)) || [],\r\n nextToken: result.NextToken,\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n\r\n async updateItem(\r\n TableName: string,\r\n key: object,\r\n condition: string,\r\n update: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n ReturnValues: ReturnValue = ReturnValue.UPDATED_NEW,\r\n ReturnValuesOnFailure: ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure.ALL_OLD\r\n ) {\r\n const input: UpdateItemCommandInput = {\r\n TableName,\r\n Key: marshall(key),\r\n ConditionExpression: condition,\r\n UpdateExpression: update,\r\n ExpressionAttributeNames: attributeName,\r\n ExpressionAttributeValues: attributeValue,\r\n ReturnValues,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnValuesOnConditionCheckFailure: ReturnValuesOnFailure,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new UpdateItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Update', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n return unmarshall(result.Attributes || {});\r\n }\r\n\r\n async deleteItem(\r\n TableName: string,\r\n key: object,\r\n condition: string,\r\n attributeName?: Record<string, string>,\r\n attributeValue?: Record<string, AttributeValue>,\r\n ReturnValues: ReturnValue = ReturnValue.ALL_OLD,\r\n ReturnValuesOnFailure: ReturnValuesOnConditionCheckFailure = ReturnValuesOnConditionCheckFailure.ALL_OLD\r\n ) {\r\n const input: DeleteItemCommandInput = {\r\n TableName,\r\n Key: marshall(key),\r\n ConditionExpression: condition,\r\n ExpressionAttributeNames: attributeName,\r\n ExpressionAttributeValues: attributeValue,\r\n ReturnValues,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES,\r\n ReturnValuesOnConditionCheckFailure: ReturnValuesOnFailure,\r\n ReturnItemCollectionMetrics: this.returnItemCollectionMetrics,\r\n };\r\n\r\n const command = new DeleteItemCommand(input);\r\n const result = await this.client.send(command);\r\n this.log('Delete', result.ConsumedCapacity, result.ItemCollectionMetrics);\r\n return unmarshall(result.Attributes || {});\r\n }\r\n\r\n async getItemByIndex(\r\n TableName: string, \r\n index: string, \r\n keyCondition: string, \r\n consistent: boolean = false, \r\n projection?: string, \r\n attributeName?: Record<string, string>, \r\n attributeValue?: Record<string, AttributeValue>,\r\n lastEvaluatedKey?: Record<string, AttributeValue>\r\n ) {\r\n const input: QueryCommandInput = {\r\n TableName,\r\n IndexName: index,\r\n KeyConditionExpression: keyCondition,\r\n ExpressionAttributeValues: attributeValue,\r\n ExclusiveStartKey: lastEvaluatedKey,\r\n ConsistentRead: consistent,\r\n ProjectionExpression: projection,\r\n ExpressionAttributeNames: attributeName,\r\n ReturnConsumedCapacity: ReturnConsumedCapacity.INDEXES\r\n }\r\n \r\n const command = new QueryCommand(input);\r\n const result = await this.client.send(command);\r\n this.log(\"GetItemByIndex\", result.ConsumedCapacity);\r\n return { \r\n Items: result.Items?.map(item => unmarshall(item)) || [],\r\n lastEvaluatedKey: result.LastEvaluatedKey,\r\n };\r\n }\r\n}\r\n\r\nexport default DynamoDBUtility;\r\n","{\r\n \"$id\": \"standards\",\r\n \"definitions\": {\r\n \"lowercaseText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]*$\"\r\n },\r\n \"lowercaseText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,10}$\"\r\n },\r\n \"lowercaseText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,16}$\"\r\n },\r\n \"lowercaseText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,30}$\"\r\n },\r\n \"lowercaseText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,50}$\"\r\n },\r\n \"lowercaseText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,256}$\"\r\n },\r\n \"text\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).*$\"\r\n },\r\n \"text10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,10}$\"\r\n },\r\n \"text16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,16}$\"\r\n },\r\n \"text30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,30}$\"\r\n },\r\n \"text50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,50}$\"\r\n },\r\n \"text256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,256}$\"\r\n },\r\n \"requiredText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).+$\"\r\n },\r\n \"requiredText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,10}$\"\r\n },\r\n \"requiredText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,16}$\"\r\n },\r\n \"requiredText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,30}$\"\r\n },\r\n \"requiredText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,50}$\"\r\n },\r\n \"requiredText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,256}$\"\r\n },\r\n \"url\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^https://[^\\\\s/$.?#].[^\\\\s]*$\",\r\n \"maxLength\": 2048\r\n },\r\n \"uuid\": {\r\n \"type\": \"string\",\r\n \"minLength\": 1,\r\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"\r\n },\r\n \"productKey\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"variantId\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\r\n \"phone\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[0-9]{10}$\"\r\n },\r\n \"email\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[^\\\\s]+@[^\\\\s]+\\\\.[^\\\\s]+$\"\r\n },\r\n \"addressLine1\": { \"$ref\": \"#/definitions/requiredText50\" },\r\n \"addressLine2\": { \"$ref\": \"#/definitions/text50\" },\r\n \"city\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"postalCode\": { \"$ref\": \"#/definitions/requiredText16\" },\r\n \"state\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"AP\", \"AR\", \"AS\", \"BR\", \"CT\", \"GA\", \"GJ\", \"HR\", \"HP\", \"JH\", \"KA\", \"KL\", \"MP\", \"MH\", \"MN\", \"ML\", \"MZ\", \"NL\", \"OR\", \"PB\", \"RJ\", \"SK\", \"TN\", \"TG\", \"TR\", \"UP\", \"UT\", \"WB\", \"AN\", \"CH\", \"DH\", \"LD\", \"DL\", \"PY\", \"LA\", \"JK\"]\r\n },\r\n \"country\": {\r\n \"type\": \"string\",\r\n \"enum\": [\r\n \"IN\"\r\n ]\r\n },\r\n \"currency\": {\r\n \"type\": \"string\",\r\n \"enum\": [\r\n \"INR\"\r\n ]\r\n },\r\n \"locale\": {\r\n \"type\": \"string\",\r\n \"enum\": [\r\n \"en-IN\"\r\n ]\r\n },\r\n \"addressType\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"shipping\", \"billing\", \"shipping&billing\"]\r\n },\r\n \"address\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"firstName\": {\"$ref\": \"standards#/definitions/firstName\"},\r\n \"lastName\": { \"$ref\": \"standards#/definitions/lastName\" },\r\n \"phone\": { \"$ref\": \"standards#/definitions/phone\" },\r\n \"email\": { \"$ref\": \"standards#/definitions/email\" },\r\n \"addressLine1\": { \"$ref\": \"standards#/definitions/addressLine1\" },\r\n \"addressLine2\": { \"$ref\": \"standards#/definitions/addressLine2\" },\r\n \"city\": { \"$ref\": \"standards#/definitions/city\" },\r\n \"postalCode\": { \"$ref\": \"standards#/definitions/postalCode\" },\r\n \"state\": { \"$ref\": \"standards#/definitions/state\" },\r\n \"country\": { \"$ref\": \"standards#/definitions/country\" }\r\n },\r\n \"required\": [\"firstName\", \"lastName\", \"phone\", \"email\", \"addressLine1\", \"postalCode\", \"state\", \"country\"]\r\n }\r\n }\r\n}","import SchemaDefinitions from './definition.json';\r\n\r\nconst Schema = {\r\n getStandardSchemaDefinition() {\r\n return SchemaDefinitions;\r\n }\r\n}\r\n\r\nexport default Schema;\r\n","import { importPKCS8, importSPKI, jwtVerify, SignJWT} from 'jose';\r\nimport ErrorTypes from '../enums/ErrorTypes';\r\nimport Logger from '../Logger';\r\nimport Utils from '../Utils';\r\nimport ResponseUtility from '../Utils/response';\r\nimport assert from 'assert';\r\nimport Fetch from '../Utils/fetch';\r\n\r\ntype StringifiedJSONArray = string;\r\n\r\nexport interface AuthUtilityConfig {\r\n maxTokenAge: string;\r\n userPrivateKeys: StringifiedJSONArray;\r\n userPublicKeys: StringifiedJSONArray;\r\n anonymousPrivateKeys: StringifiedJSONArray;\r\n anonymousPublicKeys: StringifiedJSONArray;\r\n systemPrivateKeys: StringifiedJSONArray;\r\n systemPublicKeys: StringifiedJSONArray;\r\n adminPrivateKeys: StringifiedJSONArray;\r\n adminPublicKeys: StringifiedJSONArray;\r\n}\r\n\r\nexport const DefaultAuthUtilityConfig: Readonly<AuthUtilityConfig> = {\r\n maxTokenAge: '30 days',\r\n userPrivateKeys: '[]',\r\n userPublicKeys: '[]',\r\n anonymousPrivateKeys: '[]',\r\n anonymousPublicKeys: '[]',\r\n systemPrivateKeys: '[]',\r\n systemPublicKeys: '[]',\r\n adminPrivateKeys: '[]',\r\n adminPublicKeys: '[]',\r\n};\r\n\r\nexport type AuthTokenType = 'Anon' | 'User' | 'System' | 'Admin' | 'CDN';\r\n\r\nexport interface AuthMiddlewareConfig {\r\n allowAnonymous: boolean;\r\n allowSystem: boolean;\r\n allowUser: boolean;\r\n allowCDN: boolean;\r\n}\r\n\r\nexport const DefaultAuthMiddlewareConfig: Readonly<AuthMiddlewareConfig> = {\r\n allowAnonymous: false,\r\n allowSystem: true,\r\n allowUser: true,\r\n allowCDN: false\r\n};\r\n\r\n/**\r\n * A utility class for JWT authentication and authorization.\r\n */\r\nclass AuthUtility {\r\n private maxTokenAge: string;\r\n private userPrivateKeys: string[];\r\n private userPublicKeys: string[];\r\n private anonymousPrivateKeys: string[];\r\n private anonymousPublicKeys: string[];\r\n private systemPrivateKeys: string[];\r\n private systemPublicKeys: string[];\r\n private adminPrivateKeys: string[];\r\n private adminPublicKeys: string[];\r\n\r\n /**\r\n * Initializes the AuthUtility class with a configuration.\r\n * @param config The configuration for the utility (optional).\r\n */\r\n constructor(config: Partial<AuthUtilityConfig> = DefaultAuthUtilityConfig) {\r\n const {\r\n maxTokenAge,\r\n userPrivateKeys,\r\n userPublicKeys,\r\n anonymousPrivateKeys,\r\n anonymousPublicKeys,\r\n systemPrivateKeys,\r\n systemPublicKeys,\r\n adminPrivateKeys,\r\n adminPublicKeys,\r\n } = { ...DefaultAuthUtilityConfig, ...config };\r\n\r\n this.maxTokenAge = maxTokenAge;\r\n\r\n this.userPrivateKeys = JSON.parse(userPrivateKeys);\r\n this.userPublicKeys = JSON.parse(userPublicKeys);\r\n\r\n this.anonymousPrivateKeys = JSON.parse(anonymousPrivateKeys);\r\n this.anonymousPublicKeys = JSON.parse(anonymousPublicKeys);\r\n\r\n this.systemPrivateKeys = JSON.parse(systemPrivateKeys);\r\n this.systemPublicKeys = JSON.parse(systemPublicKeys);\r\n\r\n this.adminPrivateKeys = JSON.parse(adminPrivateKeys);\r\n this.adminPublicKeys = JSON.parse(adminPublicKeys);\r\n\r\n this.logWarnings();\r\n }\r\n\r\n /**\r\n * Logs warnings if the number of keys exceeds recommended limits.\r\n */\r\n private logWarnings() {\r\n const warn = (type: string, keys: string[], limit: number) =>\r\n keys.length > limit &&\r\n Logger.logWarning(\r\n 'AuthUtility',\r\n `More than ${limit} ${type} keys provided. This is not recommended.`\r\n );\r\n\r\n warn('user private', this.userPrivateKeys, 3);\r\n warn('user public', this.userPublicKeys, 3);\r\n warn('anonymous private', this.anonymousPrivateKeys, 1);\r\n warn('anonymous public', this.anonymousPublicKeys, 3);\r\n warn('system private', this.systemPrivateKeys, 1);\r\n warn('system public', this.systemPublicKeys, 3);\r\n warn('admin private', this.adminPrivateKeys, 1);\r\n warn('admin public', this.adminPublicKeys, 3);\r\n }\r\n\r\n private async createSignedJWT(payload: any, privateKeyString: string, expiration: string){\r\n const privateKey = await importPKCS8(privateKeyString, 'RS256');\r\n const token = await new SignJWT(payload)\r\n .setProtectedHeader({ alg: 'RS256' })\r\n .setExpirationTime(expiration)\r\n .setIssuedAt()\r\n .sign(privateKey);\r\n\r\n return token;\r\n }\r\n\r\n private async verifySignedJWT(token: string, publicKeyString: string[], expiration: string){\r\n for(let i = publicKeyString.length - 1; i > 0 ; i--){\r\n try { \r\n const publicKey = await importSPKI(publicKeyString[i], 'RS256')\r\n const jwt = await jwtVerify(token, publicKey, { clockTolerance: 30, maxTokenAge: expiration });\r\n return jwt.payload;\r\n } catch (error) {\r\n // Try with the next oldest key\r\n continue;\r\n }\r\n }\r\n\r\n const publicKey = await importSPKI(publicKeyString[0], 'RS256')\r\n const jwt = await jwtVerify(token, publicKey, { clockTolerance: 30, maxTokenAge: expiration });\r\n return jwt.payload;\r\n }\r\n\r\n \r\n /**\r\n * Creates an anonymous token with the given ID and additional data.\r\n *\r\n * @param id - The unique identifier for the token. Must be a valid UUID.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT as a string.\r\n * @throws Will throw an error if no anonymous private keys are found or if the ID is not a valid UUID.\r\n */\r\n async createAnonymousToken(id: string, additionalData?: object): Promise<string> {\r\n assert(this.anonymousPrivateKeys.length, ErrorTypes.ANONYMOUS_PRIVATE_KEY_NOT_FOUND);\r\n\r\n assert(Utils.isUUID(id), ErrorTypes.INVALID_UUID);\r\n const payload = {\r\n id,\r\n type: 'Anon',\r\n ...additionalData\r\n };\r\n\r\n return await this.createSignedJWT(payload, this.anonymousPrivateKeys[this.anonymousPrivateKeys.length - 1], this.maxTokenAge);\r\n }\r\n\r\n /**\r\n * Verifies an anonymous token by checking its signature and payload type.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @returns The payload of the verified token.\r\n * @throws Will throw an error if no anonymous public keys are found or if the token type is invalid.\r\n */\r\n async verifyAnonymousToken(token: string){\r\n assert(this.anonymousPublicKeys.length, ErrorTypes.ANONYMOUS_PUBLIC_KEY_NOT_FOUND);\r\n const payload = await this.verifySignedJWT(token, this.anonymousPublicKeys, this.maxTokenAge);\r\n assert(payload.type === 'Anon', ErrorTypes.INVALID_AUTH_TYPE);\r\n return payload;\r\n }\r\n\r\n /**\r\n * Creates a signed JWT token for a user.\r\n *\r\n * @param id - The UUID of the user.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT token as a string.\r\n * @throws Will throw an error if no user private keys are found or if the provided id is not a valid UUID.\r\n */\r\n async createUserToken(id: string, additionalData?: object): Promise<string> {\r\n assert(this.userPrivateKeys.length, ErrorTypes.USER_PRIVATE_KEY_NOT_FOUND);\r\n assert(Utils.isUUID(id), ErrorTypes.INVALID_UUID);\r\n\r\n const payload = {\r\n id,\r\n type: 'User',\r\n ...additionalData\r\n };\r\n return await this.createSignedJWT(payload, this.userPrivateKeys[this.userPrivateKeys.length - 1], this.maxTokenAge);\r\n }\r\n\r\n /**\r\n * Verifies the provided user token by checking its signature and payload.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @returns The payload of the verified token if valid.\r\n * @throws Will throw an error if no user public keys are found or if the token type is invalid.\r\n */\r\n async verifyUserToken(token: string){\r\n assert(this.userPublicKeys.length, ErrorTypes.USER_PUBLIC_KEY_NOT_FOUND);\r\n const payload =await this.verifySignedJWT(token, this.userPublicKeys, this.maxTokenAge);\r\n assert(payload.type === 'User', ErrorTypes.INVALID_AUTH_TYPE);\r\n return payload;\r\n }\r\n\r\n /**\r\n * Creates a signed JWT (JSON Web Token) for a system with the given ID and optional additional data.\r\n *\r\n * @param id - The unique identifier for the system.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT as a string.\r\n * @throws Will throw an error if no system private keys are found.\r\n */\r\n async createSystemToken(id: string, additionalData?: object): Promise<string> {\r\n assert(this.systemPrivateKeys.length, ErrorTypes.SYSTEM_PRIVATE_KEY_NOT_FOUND);\r\n\r\n const payload = {\r\n id,\r\n type: 'System',\r\n ...additionalData\r\n };\r\n return await this.createSignedJWT(payload, this.systemPrivateKeys[this.systemPrivateKeys.length - 1], '5 min');\r\n }\r\n\r\n /**\r\n * Verifies a system token by checking its signature and payload type.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @returns The payload of the verified token.\r\n * @throws Will throw an error if no system public keys are found or if the token type is not 'System'.\r\n */\r\n async verifySystemToken(token: string){\r\n assert(this.systemPublicKeys.length, ErrorTypes.USER_PUBLIC_KEY_NOT_FOUND);\r\n const payload = await this.verifySignedJWT(token, this.systemPublicKeys, '5 min');\r\n assert(payload.type === 'System', ErrorTypes.INVALID_AUTH_TYPE);\r\n return payload;\r\n }\r\n\r\n /**\r\n * Creates a signed JWT token for an admin user.\r\n *\r\n * @param email - The email of the admin user.\r\n * @param additionalData - Optional additional data to include in the token payload.\r\n * @returns A promise that resolves to the signed JWT token string.\r\n * @throws Will throw an error if no admin private keys are found or if the provided id is not a valid UUID.\r\n */\r\n async createAdminToken(email: string, verifier: string, additionalData?: object): Promise<string> {\r\n assert(this.adminPrivateKeys.length, ErrorTypes.ADMIN_PRIVATE_KEY_NOT_FOUND);\r\n\r\n assert(Utils.isEmail(email), ErrorTypes.INVALID_EMAIL);\r\n assert(Utils.isURL(verifier), ErrorTypes.INVALID_VERIFIER);\r\n const payload = {\r\n email,\r\n type: 'Admin',\r\n verifier: verifier,\r\n ...additionalData\r\n };\r\n return await this.createSignedJWT(payload, this.adminPrivateKeys[this.adminPrivateKeys.length - 1], this.maxTokenAge);\r\n }\r\n\r\n /**\r\n * Verifies the provided admin token by checking its signature and payload.\r\n * Ensures that the token is signed with one of the known admin public keys\r\n * and that the payload type is 'Admin'.\r\n *\r\n * @param token - The JWT token to be verified.\r\n * @param permissions - The permissions required for the admin user.\r\n * @param authenticate - Whether to authenticate the token with the verifier.\r\n * @returns The payload of the verified token.\r\n * @throws Will throw an error if no admin public keys are found or if the token is invalid or if the admin doesn't have proper permissions.\r\n */\r\n async verifyAdminToken(token: string, permissions: string[], authenticate: boolean){\r\n assert(this.adminPublicKeys.length, ErrorTypes.ADMIN_PUBLIC_KEY_NOT_FOUND);\r\n const payload = await this.verifySignedJWT(token, this.adminPublicKeys, this.maxTokenAge);\r\n assert(payload.type === 'Admin', ErrorTypes.INVALID_AUTH_TYPE);\r\n\r\n if(authenticate) {\r\n const response = await Fetch(payload.verifier as string, '', 'POST', {}, { token, permissions });\r\n assert(response.data.isTokenValid === true, ErrorTypes.INVALID_TOKEN);\r\n \r\n if(response.data.hasPermissions !== true){\r\n throw ResponseUtility.generateError(403, ErrorTypes.INVALID_PERMISSIONS)\r\n }\r\n }\r\n\r\n return payload;\r\n }\r\n\r\n /**\r\n * Middleware function to handle authentication based on different token types.\r\n * It verifies the token and sets the authentication details in the response locals.\r\n *\r\n * @param {Partial<AuthMiddlewareConfig>} [config=DefaultAuthMiddlewareConfig] - Configuration object to customize the middleware behavior.\r\n * @returns Middleware function to handle authentication.\r\n */\r\n AuthMiddleware(config: Partial<AuthMiddlewareConfig> = DefaultAuthMiddlewareConfig, permissions: string[] = []) {\r\n const { allowAnonymous, allowSystem, allowUser, allowCDN } = { ...DefaultAuthMiddlewareConfig, ...config };\r\n return async (req: any, res: any, next: any) => {\r\n try {\r\n const [authType, token] = req.get('Authorization')?.split(' ') || [];\r\n if (!token) throw new Error(ErrorTypes.INVALID_TOKEN);\r\n\r\n let payload;\r\n switch (authType as AuthTokenType) {\r\n case 'Anon':\r\n if (!allowAnonymous) throw ResponseUtility.generateError(403, ErrorTypes.ANONYMOUS_SESSION_NOT_ALLOWED);\r\n payload = await this.verifyAnonymousToken(token);\r\n break;\r\n case 'User':\r\n if (!allowUser) throw ResponseUtility.generateError(403, ErrorTypes.USER_SESSION_NOT_ALLOWED);\r\n payload = await this.verifyUserToken(token);\r\n break;\r\n case 'System':\r\n if (!allowSystem) throw ResponseUtility.generateError(403, ErrorTypes.SYSTEM_SESSION_NOT_ALLOWED);\r\n payload = await this.verifySystemToken(token);\r\n Logger.logMessage('AuthMiddleware', `System Name - ${payload.id}`);\r\n break;\r\n case 'Admin':\r\n payload = await this.verifyAdminToken(token, permissions, true);\r\n Logger.logMessage('AuthMiddleware', `Admin - ${payload.email}`);\r\n break;\r\n case 'CDN':\r\n if (!allowCDN) throw ResponseUtility.generateError(403, ErrorTypes.CDN_SESSION_NOT_ALLOWED);\r\n assert(['E3CQMOP5FX6KD1', 'E3TNCKKZ3FOX9W'].includes(token), ErrorTypes.INVALID_TOKEN);\r\n Logger.logMessage('AuthMiddleware', `CDN DistributionId - ${token}`);\r\n break;\r\n default:\r\n throw ResponseUtility.generateError(403, ErrorTypes.INVALID_AUTH_TYPE);\r\n }\r\n\r\n res.locals.auth = { authType, token, ...payload };\r\n next();\r\n } catch (error: any) {\r\n Logger.logError('AuthMiddleware', error);\r\n ResponseUtility.handleException(\r\n 'AuthMiddleware',\r\n ResponseUtility.generateError(401, error.error || ErrorTypes.TOKEN_EXPIRED, true),\r\n res\r\n );\r\n }\r\n };\r\n }\r\n}\r\n\r\nexport default AuthUtility;\r\n\r\n","export default Object.freeze({\r\n INVALID_UUID: \"Invalid UUID\",\r\n INVALID_EMAIL: \"Invalid Email\",\r\n INVALID_TOKEN: \"Invalid Token\",\r\n TOKEN_EXPIRED: \"Token Expired\",\r\n INVALID_VERIFIER: \"Invalid Verifier\",\r\n INVALID_PERMISSIONS: \"Invalid Permissions\",\r\n INVALID_AUTH_TYPE: \"Invalid Authorization Type\",\r\n USER_PRIVATE_KEY_NOT_FOUND: \"User Private Key Not Found\",\r\n USER_PUBLIC_KEY_NOT_FOUND: \"User Public Key Not Found\",\r\n ANONYMOUS_PRIVATE_KEY_NOT_FOUND: \"Anonymous Private Key Not Found\",\r\n ANONYMOUS_PUBLIC_KEY_NOT_FOUND: \"Anonymous Public Key Not Found\",\r\n SYSTEM_PRIVATE_KEY_NOT_FOUND: \"System Private Key Not Found\",\r\n SYSTEM_PUBLIC_KEY_NOT_FOUND: \"System Public Key Not Found\",\r\n ADMIN_PRIVATE_KEY_NOT_FOUND: \"Admin Private Key Not Found\",\r\n ADMIN_PUBLIC_KEY_NOT_FOUND: \"Admin Public Key Not Found\",\r\n SECRET_TOKEN_NOT_FOUND: \"Secret Token Not Found\",\r\n ANONYMOUS_SESSION_NOT_ALLOWED: \"Anonymous Session Not Allowed\",\r\n USER_SESSION_NOT_ALLOWED: \"User Session Not Allowed\",\r\n SYSTEM_SESSION_NOT_ALLOWED: \"System Session Not Allowed\",\r\n CDN_SESSION_NOT_ALLOWED: \"CDN Session Not Allowed\",\r\n INTERNAL_SERVER_ERROR: \"Internal Server Error\",\r\n SOMETHING_WENT_WRONG: 'Something went wrong'\r\n})","import util from 'node:util';\r\nconst Logger = {\r\n logException: (functionName: string, error: any) => {\r\n console.error(`Exception Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logError: (functionName: string, error: any) => {\r\n console.error(`Error Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logWarning: (functionName: string, message: any) => {\r\n console.warn(`Warning in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logMessage: (functionName: string, message: any) => {\r\n console.log(`Message in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logInvalidPayload: (functionName: string, errorMessage: string) => {\r\n console.error(`Invalid Payload received for Function: ${functionName}, Error: ${Logger.inspect(errorMessage)}`);\r\n },\r\n\r\n inspect: (context: any) => {\r\n return (typeof context === \"string\" ? context : util.inspect(context));\r\n }\r\n}\r\n\r\nexport default Logger;","import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, variantId: string) => {\r\n return `${key}#${variantId}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, variantId] = searchId.split('#');\r\n return {\r\n key,\r\n variantId\r\n }\r\n },\r\n}\r\n\r\nexport default Utils;\r\n","import ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport const ResponseUtility = {\r\n handleException: (functionName: string, error: any, res: any) => {\r\n if (error.knownError) {\r\n error.logError && Logger.logError(functionName, error);\r\n res.status(error.status).json({\r\n status: error.status,\r\n error: error.error\r\n });\r\n } else if(error.status && error.error) {\r\n Logger.logException(functionName, error);\r\n res.status(error.status).json({\r\n ...error.error,\r\n status: error.status,\r\n });\r\n } else {\r\n Logger.logException(functionName, error);\r\n res.status(500).json({\r\n status: 500,\r\n error: ErrorTypes.INTERNAL_SERVER_ERROR\r\n })\r\n }\r\n },\r\n\r\n generateResponse: (status: number, data?: any, error?: string) => {\r\n return {\r\n status,\r\n data,\r\n error\r\n }\r\n },\r\n\r\n generateError: (status: number, error: string, knownError: Boolean = true, logError: boolean = false) => {\r\n return {\r\n status,\r\n error,\r\n knownError,\r\n logError\r\n }\r\n }\r\n}\r\n\r\nexport default ResponseUtility;","\"use client\";\r\n\r\nimport ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport type ErrorType = {\r\n status: number;\r\n statusText: string;\r\n error: any;\r\n};\r\n\r\nexport type SuccessType = {\r\n status: number;\r\n statusText: string;\r\n data: any;\r\n};\r\n\r\n/**\r\n * Makes an HTTP request to the specified endpoint using the provided parameters.\r\n *\r\n * @param {string} baseURL - The base URL of the API.\r\n * @param {string} endpoint - The specific endpoint to call.\r\n * @param {'GET' | 'POST' | 'PATCH' | 'DELETE'} [method='GET'] - The HTTP method to use for the request.\r\n * @param {Record<string, string>} [headers={}] - Additional headers to include in the request.\r\n * @param {any} [payload] - The payload to send with the request, if applicable.\r\n * @returns {Promise<SuccessType>} - A promise that resolves to the response data if the request is successful.\r\n * @throws {ErrorType} - Throws an error if the request fails.\r\n */\r\nconst Fetch = async (\r\n baseURL: string,\r\n endpoint: string,\r\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET',\r\n headers: Record<string, string> = {},\r\n payload?: any,\r\n): Promise<SuccessType> => {\r\n const options: RequestInit = {\r\n method,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n ...headers,\r\n },\r\n };\r\n\r\n if (method !== 'GET' && payload) {\r\n options.body = JSON.stringify(payload);\r\n }\r\n\r\n const completeURL = `${baseURL}${endpoint ? ('/' + endpoint) : ''}`\r\n try {\r\n const response: any = await fetch(completeURL, options);\r\n\r\n if (!response.ok) {\r\n const errorBody: any = await response.json().catch(() => response.text());\r\n\r\n throw {\r\n status: response.status,\r\n statusText: response.statusText,\r\n error: errorBody ? errorBody : {\r\n status: response.status,\r\n error: response.statusText,\r\n }\r\n } as ErrorType;\r\n }\r\n\r\n const body = await response.json();\r\n\r\n Logger.logMessage('Fetch', `API call successful: URL-${completeURL}, Status- ${response.status}`);\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n data: body.data,\r\n } as SuccessType;\r\n } catch (err: any) {\r\n \r\n Logger.logError('Fetch', `API call failed: URL-${completeURL}, Status- ${err.status || 500}, Error- ${Logger.inspect(err.error || err)}`);\r\n throw {\r\n status: err.status || 500,\r\n statusText: err.statusText || ErrorTypes.INTERNAL_SERVER_ERROR,\r\n error: err.error || {\r\n status: err.status || 500,\r\n error: err.statusText || ErrorTypes.SOMETHING_WENT_WRONG,\r\n }\r\n } as ErrorType;\r\n }\r\n};\r\n\r\nexport default Fetch;\r\n","import BaseModel, { BaseAttributes } from \"./Base\";\r\n\r\nexport enum AddressType {\r\n BILLING = \"billing\",\r\n SHIPPING = \"shipping\",\r\n BILLING_AND_SHIPPING = \"billing&shipping\",\r\n NONE = \"none\",\r\n}\r\n\r\nexport type AddressAttributes = BaseAttributes & {\r\n id: string;\r\n firstName: string;\r\n lastName: string;\r\n phone: string;\r\n email: string;\r\n addressLine1: string;\r\n addressLine2?: string;\r\n city: string;\r\n postalCode: string\r\n state: string;\r\n country: string;\r\n isBillingAddress: boolean;\r\n isShippingAddress: boolean;\r\n};\r\n\r\nexport type AddressData = Required<AddressAttributes>;\r\n\r\n/**\r\n * Represents a physical address associated with a customer or order.\r\n * Handles both billing and shipping address types.\r\n */\r\nexport default class AddressModel extends BaseModel {\r\n protected id: string;\r\n protected firstName: string;\r\n protected lastName: string;\r\n protected phone: string;\r\n protected email: string;\r\n protected addressLine1: string;\r\n protected addressLine2: string;\r\n protected city: string;\r\n protected postalCode: string\r\n protected state: string;\r\n protected country: string;\r\n protected isBillingAddress: boolean;\r\n protected isShippingAddress: boolean;\r\n\r\n /**\r\n * Creates an instance of AddressModel.\r\n * @param data - The initial address attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: AddressAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.firstName = data.firstName;\r\n this.lastName = data.lastName;\r\n this.phone = data.phone;\r\n this.email = data.email;\r\n this.addressLine1 = data.addressLine1;\r\n this.addressLine2 = data.addressLine2 || '';\r\n this.city = data.city;\r\n this.postalCode = data.postalCode;\r\n this.state = data.state;\r\n this.country = data.country;\r\n this.isBillingAddress = data.isBillingAddress;\r\n this.isShippingAddress = data.isShippingAddress;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the address's current state.\r\n * Includes all address fields and base model fields.\r\n * @returns AddressData object suitable for serialization or API responses.\r\n */\r\n getDetails(): AddressData {\r\n return {\r\n ...super.getDetails(),\r\n id: this.getId(),\r\n firstName: this.getFirstName(),\r\n lastName: this.getLastName(),\r\n phone: this.getPhone(),\r\n email: this.getEmail(),\r\n addressLine1: this.getAddressLine1(),\r\n addressLine2: this.getAddressLine2(),\r\n city: this.getCity(),\r\n postalCode: this.getPostalCode(),\r\n state: this.getState(),\r\n country: this.getCountry(),\r\n isBillingAddress: this.getIsBillingAddress(),\r\n isShippingAddress: this.getIsShippingAddress(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the unique identifier for the address.\r\n * @returns The address ID.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the first name associated with the address.\r\n * @returns The first name.\r\n */\r\n getFirstName(): string {\r\n return this.firstName;\r\n }\r\n\r\n /**\r\n * Gets the last name associated with the address.\r\n * @returns The last name.\r\n */\r\n getLastName(): string {\r\n return this.lastName;\r\n }\r\n\r\n /**\r\n * Gets the phone number associated with the address.\r\n * @returns The phone number.\r\n */\r\n getPhone(): string {\r\n return this.phone;\r\n }\r\n\r\n /**\r\n * Gets the email address associated with the address.\r\n * @returns The email address.\r\n */\r\n getEmail(): string {\r\n return this.email;\r\n }\r\n\r\n /**\r\n * Gets the primary address line (e.g., street address).\r\n * @returns The first address line.\r\n */\r\n getAddressLine1(): string {\r\n return this.addressLine1;\r\n }\r\n\r\n /**\r\n * Gets the secondary address line (e.g., apartment, suite).\r\n * Returns an empty string if not provided.\r\n * @returns The second address line or an empty string.\r\n */\r\n getAddressLine2(): string {\r\n return this.addressLine2;\r\n }\r\n\r\n /**\r\n * Gets the city name.\r\n * @returns The city.\r\n */\r\n getCity(): string {\r\n return this.city;\r\n }\r\n\r\n /**\r\n * Gets the postal code (e.g., ZIP code).\r\n * @returns The postal code.\r\n */\r\n getPostalCode(): string {\r\n return this.postalCode;\r\n }\r\n\r\n /**\r\n * Gets the state, province, or region.\r\n * @returns The state.\r\n */\r\n getState(): string {\r\n return this.state;\r\n }\r\n\r\n /**\r\n * Gets the country name or code.\r\n * @returns The country.\r\n */\r\n getCountry(): string {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Checks if this address is designated as a billing address.\r\n * @returns True if it's a billing address, false otherwise.\r\n */\r\n getIsBillingAddress(): boolean {\r\n return this.isBillingAddress;\r\n }\r\n\r\n /**\r\n * Checks if this address is designated as a shipping address.\r\n * @returns True if it's a shipping address, false otherwise.\r\n */\r\n getIsShippingAddress(): boolean {\r\n return this.isShippingAddress;\r\n }\r\n\r\n /**\r\n * Determines the type of the address based on its billing and shipping flags.\r\n * @returns The AddressType enum value representing the address's role.\r\n */\r\n getAddressType(): AddressType {\r\n if (this.isBillingAddress && this.isShippingAddress) {\r\n return AddressType.BILLING_AND_SHIPPING;\r\n } else if (this.isBillingAddress) {\r\n return AddressType.BILLING;\r\n } else if (this.isShippingAddress) {\r\n return AddressType.SHIPPING;\r\n } else {\r\n return AddressType.NONE;\r\n }\r\n }\r\n\r\n /**\r\n * Static method to check if a given AddressType includes shipping.\r\n * @param addressType - The address type to check.\r\n * @returns True if the type is SHIPPING or BILLING_AND_SHIPPING.\r\n */\r\n static checkIfShippingAddress(addressType: AddressType): boolean {\r\n return addressType === AddressType.SHIPPING || addressType === AddressType.BILLING_AND_SHIPPING;\r\n }\r\n\r\n /**\r\n * Static method to check if a given AddressType includes billing.\r\n * @param addressType - The address type to check.\r\n * @returns True if the type is BILLING or BILLING_AND_SHIPPING.\r\n */\r\n static checkIfBillingAddress(addressType: AddressType): boolean {\r\n return addressType === AddressType.BILLING || addressType === AddressType.BILLING_AND_SHIPPING;\r\n }\r\n}","export enum ImageResolution {\r\n THUMBNAIL = 'thumbnail',\r\n SMALL = 'small',\r\n MEDIUM = 'medium',\r\n LARGE = 'large',\r\n ORIGINAL = 'original',\r\n}\r\n\r\nexport type ImageInfoAttribute = {\r\n sources: { [key in ImageResolution]?: string } & { original: string };\r\n alt?: string;\r\n order?: number;\r\n label?: string;\r\n};\r\n\r\nexport type ImageInfoData = ImageInfoAttribute;\r\n\r\n/**\r\n * Represents and manages structured image data, including multiple resolutions.\r\n */\r\nexport default class ImageInfoModel {\r\n protected sources: { [key in ImageResolution]?: string } & { original: string };\r\n protected alt?: string;\r\n protected order?: number;\r\n protected label?: string;\r\n\r\n /**\r\n * Creates an instance of ImageInfoModel.\r\n * @param data - The initial image data.\r\n */\r\n constructor(data: ImageInfoAttribute) {\r\n this.sources = { ...data.sources };\r\n this.alt = data.alt;\r\n this.order = data.order;\r\n this.label = data.label;\r\n\r\n if (!this.sources.original) {\r\n throw (\"ImageInfoModel cannot be created without an 'original' source URL.\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sources object containing URLs for different resolutions.\r\n * Returns a copy to prevent external modification.\r\n */\r\n getSources() {\r\n return { ...this.sources };\r\n }\r\n\r\n /**\r\n * Gets the URL for a specific resolution key.\r\n * @param resolutionKey - The key of the desired resolution (e.g., 'thumbnail', 'medium').\r\n * @returns The URL string if the key doesn't exist, otherwise original image URL will be returned.\r\n */\r\n getSource(resolutionKey: ImageResolution): string{\r\n return this.sources[resolutionKey] || this.sources.original;\r\n }\r\n\r\n /**\r\n * Gets the alternative text for the image.\r\n */\r\n getAlt(): string | undefined {\r\n return this.alt;\r\n }\r\n\r\n /**\r\n * Gets the display order number for the image.\r\n */\r\n getOrder(): number | undefined {\r\n return this.order;\r\n }\r\n\r\n /**\r\n * Gets the display label or caption for the image.\r\n */\r\n getLabel(): string | undefined {\r\n return this.label;\r\n }\r\n\r\n /**\r\n * Sets the alternative text for the image.\r\n * @param altText - The new alt text.\r\n */\r\n setAlt(altText: string | undefined): void {\r\n this.alt = altText;\r\n // Potentially add logic here to trigger updates if needed\r\n }\r\n\r\n /**\r\n * Sets the display order for the image.\r\n * @param order - The new order number.\r\n */\r\n setOrder(order: number | undefined): void {\r\n this.order = order;\r\n }\r\n\r\n /**\r\n * Sets the display label for the image.\r\n * @param label - The new label text.\r\n */\r\n setLabel(label: string | undefined): void {\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Updates or adds a URL for a specific resolution.\r\n * @param resolutionKey - The key of the resolution to update/add.\r\n * @param url - The URL for the resolution. Set to undefined to remove.\r\n */\r\n setSource(resolutionKey: ImageResolution, url: string | undefined): void {\r\n if (url === undefined) {\r\n // Prevent deleting the 'original' key if it's required\r\n if (resolutionKey === 'original') {\r\n throw (\"Cannot remove the 'original' image source.\");\r\n return;\r\n }\r\n delete this.sources[resolutionKey];\r\n } else {\r\n this.sources[resolutionKey] = url;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a plain JavaScript object representation of the image info.\r\n */\r\n getDetails(): ImageInfoData {\r\n return {\r\n sources: this.getSources(),\r\n alt: this.getAlt(),\r\n order: this.getOrder(),\r\n label: this.getLabel(),\r\n };\r\n }\r\n}","/**\r\n * Represents the countries where the application operates or products are available.\r\n */\r\nexport enum OperationalCountry {\r\n /** India */ IN = 'IN',\r\n}\r\n \r\nexport enum OperationalCountryCurrency {\r\n /** India */ INR = 'INR',\r\n}\r\n\r\nexport enum OperationalLocale {\r\n /** India */ 'en-IN' = 'en-IN',\r\n}\r\n\r\n/**\r\n * Defines the supported ISO 4217 currency codes as an enumeration.\r\n */\r\nexport const CountryCurrencyMap = {\r\n /** India */ [OperationalCountry.IN]: OperationalCountryCurrency.INR,\r\n};\r\n\r\nexport const CurrencySymbolMap = {\r\n [OperationalCountryCurrency.INR]: '₹',\r\n}\r\n\r\n/**\r\n * Defines standard gender categories for product targeting.\r\n */\r\nexport enum GenderCategory {\r\n MALE = 'Male',\r\n FEMALE = 'Female',\r\n UNISEX = 'Unisex',\r\n KIDS = 'Kids',\r\n BOY = 'Boy',\r\n GIRL = 'Girl',\r\n}","import { CountryCode, CurrencyCode, LocaleCode } from \"./Common\"; // Assuming these are in Common.ts\r\nimport { CountryCurrencyMap, CurrencySymbolMap } from \"./Enum\"; // Ensure these maps exist\r\n\r\nexport default class PriceModel {\r\n protected price: number;\r\n protected country: CountryCode;\r\n\r\n /**\r\n * Creates an instance of PriceModel, storing the currency-correct rounded price.\r\n * @param price - The initial price value.\r\n * @param country - The country code used for rounding and determining the currency symbol.\r\n * @throws {Error} If price is negative or country/currency mapping is missing.\r\n */\r\n constructor(price: number, country: CountryCode) {\r\n this.country = country;\r\n\r\n if(price < 0) {\r\n throw new Error(\"InvalidPrice: Price cannot be negative.\");\r\n }\r\n\r\n this.price = price\r\n }\r\n\r\n /**\r\n * Gets the country code associated with this price instance.\r\n * The country code is used for determining currency and formatting rules.\r\n * @returns The CountryCode enum value.\r\n */\r\n public getCountry(): CountryCode {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Gets the rounded price value based on standard currency rules.\r\n * @returns The numeric price, rounded according to its currency's typical decimal places.\r\n */\r\n public getRoundedPrice(): number {\r\n return PriceModel.getRoundedPrice(this.price, this.country);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price.\r\n * Uses Intl.NumberFormat for accurate formatting based on locale and currency.\r\n * @param locale - The locale code (e.g., 'en-US', 'de-DE', 'en-IN') to use for formatting rules.\r\n * @param options - Configuration options for formatting.\r\n * @param options.displayAsInteger - If true, the formatted string will show the price rounded to the nearest integer (no decimals). Defaults to false.\r\n * @returns The formatted price string according to locale rules.\r\n */\r\n public getFormattedString(locale: LocaleCode, options: { displayAsInteger?: boolean, currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name' } = {}): string {\r\n const displayAsInteger = options.displayAsInteger ?? false;\r\n const currency: CurrencyCode | undefined = CountryCurrencyMap[this.country];\r\n\r\n if (currency === undefined) {\r\n throw new Error('Currency mapping not found for CountryCode');\r\n }\r\n\r\n let valueToFormat = this.price;\r\n const fractionDigits = displayAsInteger ? 0 : PriceModel.getDecimalPlaces(currency);\r\n\r\n let formattingOptions: Intl.NumberFormatOptions = {\r\n style: 'currency',\r\n currency: currency,\r\n signDisplay: 'never',\r\n currencyDisplay: options.currencyDisplay,\r\n minimumFractionDigits: fractionDigits,\r\n maximumFractionDigits: fractionDigits,\r\n };\r\n\r\n if (displayAsInteger) {\r\n valueToFormat = Math.round(valueToFormat);\r\n }\r\n\r\n try {\r\n return new Intl.NumberFormat(locale, formattingOptions).format(valueToFormat);\r\n } catch (error) {\r\n console.error(`Error formatting price for locale \"${locale}\" and currency \"${currency}\":`, error);\r\n // Basic fallback without symbol if Intl fails completely\r\n return `${CurrencySymbolMap[currency] ?? currency} ${PriceModel.addThousandSeparators(valueToFormat.toFixed(fractionDigits))}`;\r\n }\r\n }\r\n\r\n /**\r\n * Helper method to determine standard decimal places for a currency.\r\n * @param currency - The currency code.\r\n * @returns The number of decimal places (0, 2, or 3 based on common rules).\r\n */\r\n private static getDecimalPlaces(currency: CurrencyCode): number {\r\n switch (currency) {\r\n case 'INR':\r\n default:\r\n return 2;\r\n }\r\n }\r\n\r\n /**\r\n * Adds basic thousand separators (commas) to a number string.\r\n * Does not handle different locale separators (e.g., periods, spaces).\r\n * @param numStr - The number string (potentially with decimals).\r\n * @returns The number string with commas added.\r\n */\r\n private static addThousandSeparators(numStr: string): string {\r\n const parts = numStr.split('.');\r\n const integerPart = parts[0];\r\n const decimalPart = parts.length > 1 ? '.' + parts[1] : '';\r\n\r\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\r\n return formattedInteger + decimalPart;\r\n }\r\n\r\n /**\r\n * Rounds a price value according to the standard decimal places\r\n * for the currency associated with the given country.\r\n *\r\n * @param price - The price value to round. Must be a non-negative number.\r\n * @param country - The country code to determine the currency and rounding rules.\r\n * @returns The rounded price as a number.\r\n * @throws {Error} If the country code is not found in the CountryCurrencyMap or price is negative.\r\n */\r\n static getRoundedPrice(price: number, country: CountryCode): number {\r\n if (price < 0) {\r\n throw new Error(\"Price cannot be negative for rounding.\");\r\n }\r\n\r\n const currency: CurrencyCode | undefined = CountryCurrencyMap[country];\r\n if (currency === undefined) {\r\n throw new Error(`Currency mapping not found for CountryCode: ${country}`);\r\n }\r\n\r\n const decimalPlaces = PriceModel.getDecimalPlaces(currency);\r\n const multiplier = Math.pow(10, decimalPlaces);\r\n const roundedValue = Math.round(price * multiplier) / multiplier;\r\n\r\n return roundedValue;\r\n }\r\n\r\n /**\r\n * Static method to retrieve the currency code associated with a given country code.\r\n * Uses the `CountryCurrencyMap` to find the corresponding currency.\r\n *\r\n * @param country - The country code (e.g., 'IN') for which to find the currency.\r\n * @returns The currency code (e.g., 'INR') as a string, or undefined if the mapping doesn't exist.\r\n */\r\n static getCurrency(country: CountryCode): string {\r\n return CountryCurrencyMap[country];\r\n }\r\n\r\n}\r\n\r\nPriceModel.getRoundedPrice(-1, 'IN')","import BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, ISODateTime, LocaleCode, LocalizedString, RegionalPrice, RegionalPriceList } from \"./Common\";\r\n\r\nexport enum CouponType {\r\n COUPON = \"coupon\",\r\n AUTOMATIC = \"automatic\",\r\n}\r\n\r\nexport enum CouponDiscountMethod {\r\n FLAT = \"flat\",\r\n PERCENTAGE = \"percentage\",\r\n}\r\n\r\nexport enum CouponCategory {\r\n SHIPPING = \"SHIPPING\",\r\n CUSTOMER = \"CUSTOMER\",\r\n}\r\n\r\nexport enum ApplicableTo {\r\n ALL = \"all\",\r\n FTB = \"ftb\",\r\n}\r\n\r\nexport type CouponAttribute = BaseAttributes & {\r\n couponCode: string;\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n type: CouponType;\r\n customerId?: string;\r\n validFrom: ISODateTime;\r\n validTo: ISODateTime;\r\n minCartValue: RegionalPriceList;\r\n maxCartDiscount: RegionalPriceList;\r\n discountMethod: CouponDiscountMethod;\r\n percentageValue?: number;\r\n applicableTo: ApplicableTo;\r\n category: CouponCategory;\r\n};\r\n\r\nexport type CouponData = Required<CouponAttribute>\r\n\r\n/**\r\n * Represents a discount coupon, extending BaseModel.\r\n */\r\nexport default class CouponModel extends BaseModel {\r\n protected couponCode: string;\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected type: CouponType;\r\n protected customerId?: string;\r\n protected validFrom: ISODateTime;\r\n protected validTo: ISODateTime;\r\n protected minCartValue: RegionalPriceList;\r\n protected maxCartDiscount: RegionalPriceList;\r\n protected discountMethod: CouponDiscountMethod;\r\n protected percentageValue: number;\r\n protected applicableTo: ApplicableTo;\r\n protected category: CouponCategory;\r\n\r\n /**\r\n * Creates an instance of CouponModel.\r\n * @param data - The initial coupon attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: CouponAttribute, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.couponCode = data.couponCode;\r\n this.name = { ...data.name };\r\n this.description = { ...data.description };\r\n this.type = data.type;\r\n this.customerId = data.customerId;\r\n this.validFrom = data.validFrom && Date.parse(data.validFrom) ? new Date(data.validFrom).toISOString() : date.toISOString();\r\n this.validTo = data.validTo && Date.parse(data.validTo) ? new Date(data.validTo).toISOString() : date.toISOString();\r\n this.minCartValue = data.minCartValue.map(price => ({ ...price }));\r\n this.maxCartDiscount = data.maxCartDiscount.map(price => ({ ...price }));\r\n this.discountMethod = data.discountMethod;\r\n this.percentageValue = data.percentageValue ?? 0;\r\n this.applicableTo = data.applicableTo;\r\n this.category = data.category;\r\n }\r\n\r\n /** Gets the unique coupon code. */\r\n getCode(): string {\r\n return this.couponCode;\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon name object.\r\n * @returns A copy of the LocalizedString object for the name.\r\n */\r\n getName(): LocalizedString\r\n /**\r\n * Gets the coupon name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name.en;\r\n } else {\r\n return { ...this.name };\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon description object.\r\n * @returns A copy of the LocalizedString object for the description, or undefined.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the coupon description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description.en;\r\n } else {\r\n return { ...this.description };\r\n }\r\n }\r\n\r\n /** Gets the type of coupon (COUPON or AUTOMATIC). */\r\n getType(): CouponType {\r\n return this.type;\r\n }\r\n\r\n /** Gets the specific customer ID this coupon is limited to, if any. */\r\n getCustomerId(): string {\r\n return this.customerId ?? '';\r\n }\r\n\r\n /** Gets the ISO date string from when the coupon is valid. */\r\n getValidFrom(): ISODateTime {\r\n return this.validFrom;\r\n }\r\n\r\n /** Gets the ISO date string until when the coupon is valid. */\r\n getValidTo(): ISODateTime {\r\n return this.validTo;\r\n }\r\n\r\n /**\r\n * Gets the list of minimum cart values required for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional minimum cart values.\r\n */\r\n getMinCartValue(): RegionalPriceList\r\n /**\r\n * Gets the minimum cart value required for the coupon for a specific country.\r\n * @param country - The country code to filter the minimum value for.\r\n * @returns The regional minimum cart value for the specified country, or undefined if not set for that country.\r\n */\r\n getMinCartValue(country: CountryCode): RegionalPrice | undefined\r\n getMinCartValue(country?: CountryCode){\r\n if(country) {\r\n return this.minCartValue.find(price => price.country === country);\r\n }\r\n return this.minCartValue;\r\n }\r\n\r\n /**\r\n * Gets the list of maximum discount amounts allowed for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional maximum discount caps.\r\n */\r\n getMaxCartDiscount(): RegionalPriceList\r\n /**\r\n * Gets the maximum discount amount allowed for the coupon for a specific country.\r\n * @param country - The country code to filter the maximum discount for.\r\n * @returns The regional maximum discount cap for the specified country, or undefined if not set for that country.\r\n */\r\n getMaxCartDiscount(country: CountryCode): RegionalPrice | undefined\r\n getMaxCartDiscount(country?: CountryCode){\r\n if(country) {\r\n return this.maxCartDiscount.find(price => price.country === country);\r\n }\r\n return this.maxCartDiscount;\r\n }\r\n\r\n /** Gets the discount method (FLAT or PERCENTAGE). */\r\n getDiscountMethod(): CouponDiscountMethod {\r\n return this.discountMethod;\r\n }\r\n\r\n /** Gets the percentage discount value (0-100). */\r\n getPercentageValue(): number {\r\n return this.percentageValue;\r\n }\r\n\r\n /** Gets the customer applicability rule (ALL or FTB). */\r\n getApplicableTo(): ApplicableTo {\r\n return this.applicableTo;\r\n }\r\n\r\n /** Gets the category of the coupon (SHIPPING or CUSTOMER). */\r\n getCategory(): CouponCategory {\r\n return this.category;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the coupon's details.\r\n * @returns A CouponData object.\r\n */\r\n getDetails(): CouponData {\r\n return {\r\n ...super.getDetails(),\r\n couponCode: this.getCode(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n type: this.getType(),\r\n customerId: this.getCustomerId(),\r\n validFrom: this.getValidFrom(),\r\n validTo: this.getValidTo(),\r\n minCartValue: this.getMinCartValue(),\r\n maxCartDiscount: this.getMaxCartDiscount(),\r\n discountMethod: this.getDiscountMethod(),\r\n percentageValue: this.getPercentageValue(),\r\n applicableTo: this.getApplicableTo(),\r\n category: this.getCategory(),\r\n };\r\n }\r\n\r\n /**\r\n * Checks if the coupon is currently active based on its validity dates.\r\n * @returns True if the coupon is currently within its validity period, false otherwise.\r\n */\r\n isActive(): boolean {\r\n return new Date(this.validFrom) <= new Date() && new Date(this.validTo) >= new Date();\r\n }\r\n\r\n \r\n /**\r\n * Checks if the coupon is applicable to a customer based on their status (e.g., first-time buyer).\r\n * @param ftbCustomer - A boolean indicating whether the customer is a first-time buyer.\r\n * @returns True if the coupon's applicability rule matches the customer's status, false otherwise.\r\n */\r\n isApplicableTo(ftbCustomer: boolean): boolean {\r\n return this.applicableTo === ApplicableTo.ALL || (this.applicableTo === ApplicableTo.FTB && ftbCustomer);\r\n }\r\n}","import LineItemModel from \"./LineItem\";\r\nimport BaseShoppingContainerModel, { BaseShoppingContainerAttributes, BaseShoppingContainerData } from \"./ShoppingContainer\";\r\n\r\nexport enum CartState {\r\n ACTIVE = \"ACTIVE\",\r\n FROZEN = \"FROZEN\",\r\n MERGED = \"MERGED\",\r\n ORDERED = \"ORDERED\"\r\n}\r\n\r\nexport class LineItemNotFoundError extends Error {\r\n constructor(lineItemId: string) {\r\n super(`Line item with ID '${lineItemId}' not found in the cart.`);\r\n this.name = 'LineItemNotFoundError';\r\n }\r\n}\r\n\r\n/**\r\n * Input attributes for creating or updating a CartModel.\r\n */\r\nexport type CartAttributes = BaseShoppingContainerAttributes & { \r\n state: CartState;\r\n expireAt: number;\r\n};\r\n\r\nexport type CartData = BaseShoppingContainerData & {\r\n state: CartState;\r\n expireAt: number;\r\n};\r\n\r\nexport type CartConfig = {\r\n expiresAtInSeconds: number;\r\n}\r\n\r\nexport const DEFAULT_CART_CONFIG: CartConfig = {\r\n expiresAtInSeconds: 120 * 24 * 60 * 60\r\n}\r\n\r\nexport default class CartModel extends BaseShoppingContainerModel {\r\n protected state: CartState;\r\n protected expireAt: number;\r\n protected config: CartConfig;\r\n\r\n constructor(data: CartAttributes, date: Date = new Date(), config: CartConfig = DEFAULT_CART_CONFIG) {\r\n super(data, date);\r\n this.state = data.state;\r\n this.expireAt = data.expireAt && typeof data.expireAt === 'number' ? data.expireAt : Math.floor(date.getTime()/1000) + config.expiresAtInSeconds;\r\n this.config = config;\r\n \r\n this.updateCartTotals();\r\n }\r\n\r\n public getState(): CartState {\r\n return this.state;\r\n }\r\n\r\n public getExpireAt(): number {\r\n return this.expireAt;\r\n }\r\n\r\n public isActive(): boolean {\r\n const nowSeconds = Math.ceil(Date.now() / 1000);\r\n return this.state === CartState.ACTIVE && (this.expireAt > nowSeconds);\r\n }\r\n \r\n public clearCartItems() {\r\n this.lineItems = [];\r\n this.coupons = [];\r\n this.updateCartTotals();\r\n }\r\n\r\n /**\r\n * Adds a new line item or updates the quantity of an existing one.\r\n * @param newLineItem The LineItemModel to add.\r\n * @returns The index of the added/updated line item in the internal array.\r\n */\r\n public addLineItem (newLineItem: LineItemModel) {\r\n const productKey = newLineItem.getProductKey();\r\n const variantId = newLineItem.getVariantId();\r\n let index = this.lineItems.findIndex(\r\n (item) => item.getProductKey() === productKey && item.getVariantId() === variantId\r\n );\r\n\r\n if(index >= 0){\r\n this.lineItems[index].addSubItems(newLineItem.getSubItems(), true);\r\n } else {\r\n this.lineItems.push(newLineItem);\r\n }\r\n\r\n this.updateCartTotals();\r\n return index >= 0 ? index : this.lineItems.length - 1;\r\n }\r\n\r\n /**\r\n * Updates the quantity for a specific size within a line item.\r\n * @param lineItemId The ID of the LineItemModel to update.\r\n * @param size The size identifier within the line item.\r\n * @param quantity The new quantity for the size (0 to remove).\r\n * @returns The index of the updated line item.\r\n * @throws {Error} If the line item is not found.\r\n */\r\n public updateLineItem (lineItemId: string, size: string, quantity: number) {\r\n const lineItems = this.lineItems;\r\n let index = lineItems.findIndex((item) => item.getId() === lineItemId);\r\n \r\n if(index < 0){\r\n throw new LineItemNotFoundError(lineItemId);\r\n }\r\n\r\n lineItems[index].addSubItems([{ size, quantity }], false);\r\n this.updateCartTotals();\r\n\r\n return index;\r\n }\r\n\r\n /**\r\n * Removes a line item completely from the cart.\r\n * @param lineItemId The ID of the LineItemModel to remove.\r\n * @returns The index the item previously occupied.\r\n * @throws {Error} If the line item is not found.\r\n */\r\n public removeLineItem (lineItemId: string) {\r\n const lineItems = this.lineItems;\r\n const index = lineItems.findIndex((item) => item.getId() === lineItemId);\r\n\r\n if(index < 0){\r\n throw new LineItemNotFoundError(lineItemId);\r\n }\r\n\r\n this.lineItems.splice(index, 1);\r\n this.updateCartTotals();\r\n\r\n return index;\r\n }\r\n\r\n getDetails(): CartData {\r\n return {\r\n ...super.getDetails(),\r\n state: this.getState(),\r\n expireAt: this.getExpireAt(),\r\n }\r\n }\r\n}\r\n","import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\n\r\nexport enum CustomerStatus {\r\n CREATED = \"CREATED\",\r\n REGISTERED_USER = \"REGISTERED_USER\",\r\n ACTIVATED_USER = \"ACTIVATED_USER\",\r\n EMAIL_OTP = \"EMAIL_OTP\",\r\n EMAIL_PASSWORD = \"EMAIL_PASSWORD\",\r\n PHONE_OTP = \"PHONE_OTP\",\r\n}\r\n\r\nexport type CustomerAttributes = BaseAttributes & {\r\n id: string;\r\n email: string;\r\n phone: string;\r\n firstName: string;\r\n lastName: string;\r\n isEmailVerified?: boolean;\r\n customerStatus?: Set<CustomerStatus>;\r\n};\r\n\r\n\r\ntype CustomerDataWithArrayStatus = Omit<CustomerAttributes, 'customerStatus'> & BaseData & { customerStatus: CustomerStatus[]; }\r\nexport type CustomerData = Required<CustomerDataWithArrayStatus>;\r\nexport type CustomerDataWithOutId = Omit<CustomerData, 'id'>;\r\n\r\n/**\r\n * Represents a customer entity, managing customer information and status.\r\n */\r\nexport default class CustomerModel extends BaseModel {\r\n protected id: string;\r\n protected email: string;\r\n protected phone: string;\r\n protected firstName: string;\r\n protected lastName: string;\r\n protected isEmailVerified: boolean;\r\n protected customerStatus: Set<CustomerStatus>;\r\n\r\n /**\r\n * Creates an instance of CustomerModel.\r\n * Initializes customer properties and ensures the CREATED status is always present.\r\n * @param data - The initial attributes for the customer.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: CustomerAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.email = data.email;\r\n this.phone = data.phone;\r\n this.firstName = data.firstName;\r\n this.lastName = data.lastName;\r\n this.isEmailVerified = data.isEmailVerified ?? false;\r\n this.customerStatus = new Set<CustomerStatus>(\r\n [...(data.customerStatus ? Array.from<CustomerStatus>(data.customerStatus) : []), CustomerStatus.CREATED]\r\n );\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the customer's current state.\r\n * Can optionally exclude the customer ID. Includes base model details.\r\n * @param withId - If true, includes the 'id' field. Defaults to false.\r\n * @returns CustomerData or CustomerDataWithOutId object suitable for serialization.\r\n */\r\n getDetails(withId?: false): CustomerDataWithOutId;\r\n getDetails(withId: true): CustomerData;\r\n getDetails(withId: boolean = false): CustomerData | CustomerDataWithOutId {\r\n return {\r\n ...super.getDetails(),\r\n ...(withId ? { id: this.getId() } : {}),\r\n email: this.getEmail(),\r\n phone: this.getPhone(),\r\n firstName: this.getFirstName(),\r\n lastName: this.getLastName(),\r\n isEmailVerified: this.getIsEmailVerified(),\r\n customerStatus: this.getCustomerStatus()\r\n };\r\n }\r\n\r\n /**\r\n * Gets the unique identifier for the customer.\r\n * @returns The customer ID.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the email address of the customer.\r\n * @returns The email address.\r\n */\r\n getEmail(): string {\r\n return this.email;\r\n }\r\n\r\n /**\r\n * Gets the phone number of the customer.\r\n * @returns The phone number.\r\n */\r\n getPhone(): string {\r\n return this.phone;\r\n }\r\n\r\n\r\n /**\r\n * Gets the first name of the customer.\r\n * @returns The first name.\r\n */\r\n getFirstName(): string {\r\n return this.firstName;\r\n }\r\n\r\n\r\n /**\r\n * Gets the last name of the customer.\r\n * @returns The last name.\r\n */\r\n getLastName(): string {\r\n return this.lastName;\r\n }\r\n\r\n\r\n /**\r\n * Checks if the customer's email address has been verified.\r\n * @returns True if the email is verified, false otherwise.\r\n */\r\n getIsEmailVerified(): boolean {\r\n return this.isEmailVerified;\r\n }\r\n\r\n\r\n /**\r\n * Gets the customer's current statuses as an array.\r\n * @returns An array of CustomerStatus enum values.\r\n */\r\n getCustomerStatus(): CustomerStatus[] {\r\n return Array.from(this.customerStatus);\r\n }\r\n\r\n /**\r\n * Checks if the customer has a specific status.\r\n * Note: This method currently returns void. It should likely return boolean.\r\n * @param customerStatus - The status to check for.\r\n * @returns return boolean: true if the status exists, false otherwise.\r\n */\r\n hasCustomerStatus(customerStatus: CustomerStatus): boolean {\r\n return this.customerStatus.has(customerStatus);\r\n }\r\n}\r\n","import AddressModel from \"./Address\";\r\nimport { PaymentStatus } from \"./Payment\";\r\nimport BaseShoppingContainerModel, { BaseShoppingContainerAttributes, BaseShoppingContainerData } from \"./ShoppingContainer\";\r\n\r\nexport enum OrderState {\r\n PENDING_PAYMENT = \"PENDING_PAYMENT\",\r\n PROCESSING = \"PROCESSING\",\r\n SHIPPED = \"SHIPPED\",\r\n PARTIALLY_SHIPPED = \"PARTIALLY_SHIPPED\",\r\n DELIVERED = \"DELIVERED\",\r\n CANCELLED = \"CANCELLED\",\r\n RETURNED = \"RETURNED\",\r\n REFUNDED = \"REFUNDED\",\r\n}\r\n\r\n/**\r\n * Input attributes for creating an OrderModel.\r\n * Extends CartAttributes but requires/adds order-specific fields.\r\n */\r\nexport type OrderAttributes = Required<Omit<BaseShoppingContainerAttributes, 'anonymousId'>> & {\r\n anonymousId?: string;\r\n orderNumber: string;\r\n cartId: string;\r\n paymentStatus: PaymentStatus;\r\n holdReason?: string;\r\n state: OrderState;\r\n};\r\n\r\n/**\r\n * Output data structure for an OrderModel.\r\n */\r\nexport type OrderData = BaseShoppingContainerData & OrderAttributes;\r\n\r\n\r\nexport default class OrderModel extends BaseShoppingContainerModel {\r\n protected orderNumber: string;\r\n protected cartId: string;\r\n protected paymentStatus: PaymentStatus;\r\n protected holdReason: string;\r\n protected state: OrderState;\r\n\r\n /**\r\n * Creates an instance of OrderModel.\r\n * @param data - The initial order attributes, including cart data.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n * @param config - Optional cart configuration (might be less relevant for orders).\r\n */\r\n constructor(data: OrderAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.orderNumber = data.orderNumber;\r\n this.cartId = data.cartId;\r\n this.paymentStatus = data.paymentStatus;\r\n this.holdReason = data.holdReason || '';\r\n this.state = data.state;\r\n }\r\n\r\n /**\r\n * Gets the user-facing order number.\r\n * @returns The order number string.\r\n */\r\n public getOrderNumber(): string {\r\n return this.orderNumber;\r\n }\r\n\r\n /**\r\n * Gets the ID of the cart from which this order was created.\r\n * @returns The cart ID string.\r\n */\r\n public getCartId(): string {\r\n return this.cartId;\r\n }\r\n\r\n /**\r\n * Gets the current payment status of the order.\r\n * @returns The PaymentStatus enum value.\r\n */\r\n public getPaymentStatus(): PaymentStatus {\r\n return this.paymentStatus;\r\n }\r\n\r\n /**\r\n * Gets the reason why the order might be on hold, if any.\r\n * @returns The hold reason string (empty if not on hold or no reason specified).\r\n */\r\n public getHoldReason(): string {\r\n return this.holdReason;\r\n }\r\n\r\n /**\r\n * Gets the current state of the order (e.g., PROCESSING, SHIPPED).\r\n * @returns The OrderState enum value.\r\n */\r\n public getState(): OrderState {\r\n return this.state;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the order's current state.\r\n * Includes all cart details plus order-specific information.\r\n * @returns OrderData object suitable for serialization or API responses.\r\n */\r\n getDetails(): OrderData {\r\n return {\r\n ...super.getDetails(),\r\n customerId: this.getCustomerId() as string,\r\n customerEmail: this.getCustomerEmail() as string,\r\n shippingAddress: (this.getShippingAddress() as AddressModel).getDetails(),\r\n billingAddress: (this.getBillingAddress() as AddressModel).getDetails(),\r\n orderNumber: this.getOrderNumber(),\r\n cartId: this.getCartId(),\r\n paymentStatus: this.getPaymentStatus(),\r\n holdReason: this.getHoldReason(),\r\n state: this.getState(),\r\n }\r\n }\r\n}\r\n","import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CurrencyCode, ISODateTime } from \"./Common\";\r\n\r\nexport enum PaymentStatus {\r\n PENDING = \"PENDING\",\r\n AUTHORIZED = \"AUTHORIZED\",\r\n CAPTURED = \"CAPTURED\",\r\n FAILED = \"FAILED\",\r\n REFUNDED = \"REFUNDED\",\r\n PARTIALLY_REFUNDED = \"PARTIALLY_REFUNDED\",\r\n}\r\n\r\nexport enum PaymentMode {\r\n PAY_LATER = \"PAY_LATER\",\r\n CARD = \"CARD\",\r\n CASH = \"CASH\",\r\n NET_BANKING = \"NET_BANKING\",\r\n WALLET = \"WALLET\",\r\n COD = \"COD\",\r\n UNKNOWN = \"UNKNOWN\",\r\n}\r\n\r\n/**\r\n * Input attributes for creating or updating a PaymentModel.\r\n */\r\nexport type PaymentAttributes = BaseAttributes & {\r\n txnId: string;\r\n externalId?: string;\r\n orderNumber: string;\r\n customerId: string;\r\n status: PaymentStatus;\r\n subStatus?: string;\r\n amount: number;\r\n currency: CurrencyCode;\r\n paymentMode: PaymentMode;\r\n gatewayResponse?: string;\r\n gatewayErrorCode?: string;\r\n gatewayErrorMessage?: string;\r\n amountRefunded?: number;\r\n cardLast4?: string;\r\n cardBrand?: string;\r\n transactionAt: ISODateTime;\r\n};\r\n\r\n/**\r\n * Output data structure for a PaymentModel.\r\n * Excludes potentially large or sensitive fields by default.\r\n */\r\nexport type PaymentData = Omit<PaymentAttributes, 'gatewayResponse' | 'gatewayErrorMessage'> & BaseData\r\n\r\n/**\r\n * Represents a payment transaction, attempt, or record associated with an order.\r\n */\r\nexport default class PaymentModel extends BaseModel {\r\n protected txnId: string;\r\n protected externalId?: string;\r\n protected orderNumber: string;\r\n protected customerId: string;\r\n protected status: PaymentStatus;\r\n protected subStatus?: string;\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n protected paymentMode: PaymentMode;\r\n protected gatewayResponse?: string;\r\n protected gatewayErrorCode?: string;\r\n protected gatewayErrorMessage?: string;\r\n protected amountRefunded: number;\r\n protected cardLast4?: string;\r\n protected cardBrand?: string;\r\n protected transactionAt: ISODateTime;\r\n\r\n /**\r\n * Creates an instance of PaymentModel.\r\n * @param data - The initial payment attributes.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: PaymentAttributes, date: Date = new Date()) {\r\n super(data, date); // Pass BaseAttributes to parent\r\n\r\n // Assign properties\r\n this.txnId = data.txnId;\r\n this.externalId = data.externalId;\r\n this.orderNumber = data.orderNumber;\r\n this.customerId = data.customerId;\r\n this.status = data.status;\r\n this.subStatus = data.subStatus;\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n this.paymentMode = data.paymentMode;\r\n this.gatewayResponse = data.gatewayResponse;\r\n this.gatewayErrorCode = data.gatewayErrorCode;\r\n this.gatewayErrorMessage = data.gatewayErrorMessage;\r\n this.amountRefunded = data.amountRefunded || 0; // Default to 0 if undefined\r\n this.cardLast4 = data.cardLast4;\r\n this.cardBrand = data.cardBrand;\r\n this.transactionAt = data.transactionAt;\r\n }\r\n\r\n /**\r\n * Gets the primary transaction identifier.\r\n * @returns The transaction ID string.\r\n */\r\n public getTxnId(): string { return this.txnId; }\r\n\r\n /**\r\n * Gets the external identifier, often from a payment gateway.\r\n * @returns The external ID string, or undefined if not set.\r\n */\r\n public getExternalId(): string | undefined { return this.externalId; }\r\n\r\n /**\r\n * Gets the order number associated with this payment.\r\n * @returns The order number string.\r\n */\r\n public getOrderNumber(): string { return this.orderNumber; }\r\n\r\n /**\r\n * Gets the customer ID associated with this payment.\r\n * @returns The customer ID string.\r\n */\r\n public getCustomerId(): string { return this.customerId; }\r\n\r\n /**\r\n * Gets the current status of the payment (e.g., PENDING, CAPTURED).\r\n * @returns The PaymentStatus enum value.\r\n */\r\n public getStatus(): PaymentStatus { return this.status; }\r\n\r\n /**\r\n * Gets the detailed sub-status, often provided by the payment gateway.\r\n * @returns The sub-status string, or undefined if not set.\r\n */\r\n public getSubStatus(): string | undefined { return this.subStatus; }\r\n\r\n /**\r\n * Gets the amount of the payment transaction.\r\n * @returns The payment amount number.\r\n */\r\n public getAmount(): number { return this.amount; }\r\n\r\n /**\r\n * Gets the currency code for the payment amount.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode { return this.currency; }\r\n\r\n /**\r\n * Gets the mode or method used for the payment (e.g., CARD, COD).\r\n * @returns The PaymentMode enum value.\r\n */\r\n public getPaymentMode(): PaymentMode { return this.paymentMode; }\r\n\r\n /**\r\n * Gets the raw response data from the payment gateway (potentially large).\r\n * @returns The gateway response string, or undefined if not set.\r\n */\r\n public getGatewayResponse(): string | undefined { return this.gatewayResponse; }\r\n\r\n /**\r\n * Gets the error code returned by the payment gateway, if any.\r\n * @returns The gateway error code string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorCode(): string | undefined { return this.gatewayErrorCode; }\r\n\r\n /**\r\n * Gets the error message returned by the payment gateway, if any.\r\n * @returns The gateway error message string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorMessage(): string | undefined { return this.gatewayErrorMessage; }\r\n\r\n /**\r\n * Gets the total amount that has been refunded for this transaction.\r\n * @returns The refunded amount number (defaults to 0).\r\n */\r\n public getAmountRefunded(): number { return this.amountRefunded; }\r\n\r\n /**\r\n * Gets the last 4 digits of the card used, if applicable.\r\n * @returns The card's last 4 digits string, or undefined.\r\n */\r\n public getCardLast4(): string | undefined { return this.cardLast4; }\r\n\r\n /**\r\n * Gets the brand of the card used (e.g., Visa, Mastercard), if applicable.\r\n * @returns The card brand string, or undefined.\r\n */\r\n public getCardBrand(): string | undefined { return this.cardBrand; }\r\n\r\n /**\r\n * Gets the timestamp when the transaction occurred or was recorded.\r\n * @returns The transaction timestamp as an ISO 8601 string.\r\n */\r\n public getTransactionAt(): ISODateTime { return this.transactionAt; }\r\n\r\n\r\n /**\r\n * Gets a plain data object representing the payment's current state.\r\n * @returns PaymentData object suitable for serialization or API responses.\r\n */\r\n getDetails(): PaymentData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n ...baseDetails,\r\n txnId: this.getTxnId(),\r\n externalId: this.getExternalId(),\r\n orderNumber: this.getOrderNumber(),\r\n customerId: this.getCustomerId(),\r\n status: this.getStatus(),\r\n subStatus: this.getSubStatus(),\r\n amount: this.getAmount(),\r\n currency: this.getCurrency(),\r\n paymentMode: this.getPaymentMode(),\r\n gatewayErrorCode: this.getGatewayErrorCode(),\r\n amountRefunded: this.getAmountRefunded(),\r\n cardLast4: this.getCardL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ACTA,EAAA,UAAY,YAFFA,QAAA,IAKAC,OACVA,EAAA,KAAO,OACPA,EAAA,WAAa,aAFHA,OAAA,IAKAC,QACVA,EAAA,SAAW,WACXA,EAAA,SAAW,WAFDA,QAAA,IAKAC,QACVA,EAAA,IAAM,MACNA,EAAA,IAAM,MAFIA,QAAA,ICfL,IAAKC,QACVA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,QAAU,UAJAA,QAAA,IAOCC,GAAN,cAAoC,KAAM,CAC/C,YAAYC,EAAoB,CAC9B,MAAM,sBAAsBA,CAAU,0BAA0B,EAChE,KAAK,KAAO,uBACd,CACF,EAmBaC,GAAkC,CAC7C,mBAAoB,IAAM,GAAK,GAAK,EACtC,EClCO,IAAKC,QACVA,EAAA,QAAU,UACVA,EAAA,gBAAkB,kBAClBA,EAAA,eAAiB,iBACjBA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,UAAY,YANFA,QAAA,ICEL,IAAKC,QACVA,EAAA,gBAAkB,kBAClBA,EAAA,WAAa,aACbA,EAAA,QAAU,UACVA,EAAA,kBAAoB,oBACpBA,EAAA,UAAY,YACZA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,SAAW,WARDA,QAAA,ICDL,IAAKC,QACVA,EAAA,QAAU,UACVA,EAAA,WAAa,aACbA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,mBAAqB,qBANXA,QAAA,IASAC,QACVA,EAAA,UAAY,YACZA,EAAA,KAAO,OACPA,EAAA,KAAO,OACPA,EAAA,YAAc,cACdA,EAAA,OAAS,SACTA,EAAA,IAAM,MACNA,EAAA,QAAU,UAPAA,QAAA","names":["BatchGetItemCommand","DeleteItemCommand","DynamoDBClient","ExecuteStatementCommand","GetItemCommand","PutItemCommand","QueryCommand","ScanCommand","TransactWriteItemsCommand","UpdateItemCommand","ReturnConsumedCapacity","ReturnValue","ReturnValuesOnConditionCheckFailure","ReturnItemCollectionMetrics","marshall","unmarshall","DynamoDBUtility","region","returnItemCollectionMetrics","logCapacity","message","capacity","size","TableName","item","condition","attributeName","attributeValue","ReturnValues","ReturnValuesOnFailure","input","command","result","transactItems","key","consistent","projection","keys","keyCondition","lastEvaluatedKey","filterExpression","statement","parameter","nextToken","update","index","Dynamodb_default","definition_default","Schema","definition_default","Schema_default","importPKCS8","importSPKI","jwtVerify","SignJWT","ErrorTypes_default","util","Logger","functionName","error","message","errorMessage","context","Logger_default","crypto","rnds8Pool","poolPtr","rng","regex_default","validate","uuid","regex_default","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","uuid","validate_default","v","arr","parse_default","stringToBytes","str","bytes","i","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","offset","_namespace","parse_default","unsafeStringify","crypto","native_default","v4","options","buf","offset","native_default","rnds","rng","unsafeStringify","v4_default","crypto","sha1","bytes","sha1_default","v5","v35","sha1_default","v5_default","Utils","value","namespace","v5_default","v4_default","key","variantId","searchId","Utils_default","ResponseUtility","functionName","error","res","Logger_default","ErrorTypes_default","status","data","knownError","logError","response_default","assert","Fetch","baseURL","endpoint","method","headers","payload","options","completeURL","response","errorBody","body","Logger_default","err","ErrorTypes_default","fetch_default","DefaultAuthUtilityConfig","DefaultAuthMiddlewareConfig","AuthUtility","config","maxTokenAge","userPrivateKeys","userPublicKeys","anonymousPrivateKeys","anonymousPublicKeys","systemPrivateKeys","systemPublicKeys","adminPrivateKeys","adminPublicKeys","warn","type","keys","limit","Logger_default","payload","privateKeyString","expiration","privateKey","importPKCS8","SignJWT","token","publicKeyString","i","publicKey","importSPKI","jwtVerify","id","additionalData","assert","ErrorTypes_default","Utils_default","email","verifier","permissions","authenticate","response","fetch_default","response_default","allowAnonymous","allowSystem","allowUser","allowCDN","req","res","next","authType","error","Auth_default","AddressType","ImageResolution","OperationalCountry","OperationalCountryCurrency","OperationalLocale","CountryCurrencyMap","CurrencySymbolMap","GenderCategory","PriceModel","_PriceModel","price","country","locale","options","displayAsInteger","currency","CountryCurrencyMap","valueToFormat","fractionDigits","formattingOptions","error","CurrencySymbolMap","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier","CouponType","CouponDiscountMethod","CouponCategory","ApplicableTo","CartState","LineItemNotFoundError","lineItemId","DEFAULT_CART_CONFIG","CustomerStatus","OrderState","PaymentStatus","PaymentMode"]}
|