@wildix/xbees-conversations-utils 1.2.4 → 1.2.5

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.
@@ -1,20 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAnonymousUserEmail = exports.generateAnonymousUserEmailOrThrowError = void 0;
4
- const ANONYMOUS_EMAIL_DOMAIN = 'wildix.com';
5
- const ANONYMOUS_EMAIL_PREFIX = 'anonymous-';
6
- const ANONYMOUS_STREAM_ID_REGEXP = /^[0-9A-Za-z]{12}$/;
7
- const ANONYMOUS_USER_EMAIL_REGEXP = /^anonymous-[0-9A-Za-z]{12}@wildix\.com$/;
8
- function generateAnonymousUserEmailOrThrowError(streamId) {
9
- if (!streamId.trim()) {
10
- throw new Error('Anonymous stream id must not be empty');
11
- }
12
- if (!ANONYMOUS_STREAM_ID_REGEXP.test(streamId)) {
13
- throw new Error('Anonymous stream id must contain only uppercase letters, lowercase letters, digits, and have 12 symbols length');
14
- }
15
- return `${ANONYMOUS_EMAIL_PREFIX}${streamId}@${ANONYMOUS_EMAIL_DOMAIN}`;
3
+ exports.isAnonymousUserEmail = exports.generateAnonymousUserEmail = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const ANONYMOUS_USER_EMAIL_REGEXP = /^anonymous-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}@wildix\.com$/i;
6
+ function generateAnonymousUserEmail() {
7
+ return `anonymous-${(0, uuid_1.v4)()}@wildix.com`;
16
8
  }
17
- exports.generateAnonymousUserEmailOrThrowError = generateAnonymousUserEmailOrThrowError;
9
+ exports.generateAnonymousUserEmail = generateAnonymousUserEmail;
18
10
  function isAnonymousUserEmail(value) {
19
11
  return ANONYMOUS_USER_EMAIL_REGEXP.test(value);
20
12
  }
@@ -1,15 +1,7 @@
1
- const ANONYMOUS_EMAIL_DOMAIN = 'wildix.com';
2
- const ANONYMOUS_EMAIL_PREFIX = 'anonymous-';
3
- const ANONYMOUS_STREAM_ID_REGEXP = /^[0-9A-Za-z]{12}$/;
4
- const ANONYMOUS_USER_EMAIL_REGEXP = /^anonymous-[0-9A-Za-z]{12}@wildix\.com$/;
5
- export function generateAnonymousUserEmailOrThrowError(streamId) {
6
- if (!streamId.trim()) {
7
- throw new Error('Anonymous stream id must not be empty');
8
- }
9
- if (!ANONYMOUS_STREAM_ID_REGEXP.test(streamId)) {
10
- throw new Error('Anonymous stream id must contain only uppercase letters, lowercase letters, digits, and have 12 symbols length');
11
- }
12
- return `${ANONYMOUS_EMAIL_PREFIX}${streamId}@${ANONYMOUS_EMAIL_DOMAIN}`;
1
+ import { v4 } from 'uuid';
2
+ const ANONYMOUS_USER_EMAIL_REGEXP = /^anonymous-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}@wildix\.com$/i;
3
+ export function generateAnonymousUserEmail() {
4
+ return `anonymous-${v4()}@wildix.com`;
13
5
  }
14
6
  export function isAnonymousUserEmail(value) {
15
7
  return ANONYMOUS_USER_EMAIL_REGEXP.test(value);
@@ -1,2 +1,2 @@
1
- export declare function generateAnonymousUserEmailOrThrowError(streamId: string): string;
1
+ export declare function generateAnonymousUserEmail(): string;
2
2
  export declare function isAnonymousUserEmail(value: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-conversations-utils",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -25,15 +25,17 @@
25
25
  },
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@wildix/xbees-conversations-client": "1.2.13",
29
28
  "@aws-lambda-powertools/logger": "2.18.0",
29
+ "@wildix/xbees-conversations-client": "1.2.13",
30
30
  "ioredis": "5.10.0",
31
31
  "stream-chat": "8.12.1",
32
- "tslib": "^2.5.0"
32
+ "tslib": "2.5.0",
33
+ "uuid": "10.0.0"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@tsconfig/node18": "18.2.4",
36
37
  "@tsconfig/recommended": "1.0.1",
38
+ "@types/uuid": "10.0.0",
37
39
  "@wildix/eslint-config-style-guide": "1.2.1",
38
40
  "concurrently": "7.0.0",
39
41
  "downlevel-dts": "0.10.1",