@massalabs/gossip-sdk 0.0.2-dev.20260410095334 → 0.0.2-dev.20260410113001

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/README.md CHANGED
@@ -293,9 +293,6 @@ const utils = sdk.utils;
293
293
  const result = utils.validateUserId(userId);
294
294
  if (!result.valid) console.error(result.error);
295
295
 
296
- // Validate username format
297
- const result = utils.validateUsername(username);
298
-
299
296
  // Encode/decode user IDs
300
297
  const encoded = utils.encodeUserId(rawBytes);
301
298
  const decoded = utils.decodeUserId(encodedString);
package/dist/gossip.d.ts CHANGED
@@ -155,8 +155,6 @@ declare class GossipSdk {
155
155
  interface SdkUtils {
156
156
  /** Validate a user ID format */
157
157
  validateUserId(userId: string): ValidationResult;
158
- /** Validate a username format */
159
- validateUsername(username: string): ValidationResult;
160
158
  /** Encode raw bytes to user ID string */
161
159
  encodeUserId(rawId: Uint8Array): string;
162
160
  /** Decode user ID string to raw bytes */
package/dist/gossip.js CHANGED
@@ -48,7 +48,7 @@ import { AuthService } from './services/auth.js';
48
48
  import { ProfileService } from './services/profile.js';
49
49
  import { ContactService } from './services/contact.js';
50
50
  import { SelfMessageService } from './services/selfMessage.js';
51
- import { validateUserIdFormat, validateUsernameFormat, } from './utils/validation.js';
51
+ import { validateUserIdFormat, } from './utils/validation.js';
52
52
  import { QueueManager } from './utils/queue.js';
53
53
  import { encodeUserId, decodeUserId } from './utils/userId.js';
54
54
  import { MessageStatus } from './db/index.js';
@@ -463,7 +463,6 @@ class GossipSdk {
463
463
  get utils() {
464
464
  return {
465
465
  validateUserId: validateUserIdFormat,
466
- validateUsername: validateUsernameFormat,
467
466
  encodeUserId,
468
467
  decodeUserId,
469
468
  };
@@ -6,7 +6,6 @@
6
6
  */
7
7
  import { type UserProfile } from '../db/index.js';
8
8
  import { Queries } from '../db/queries/index.js';
9
- import { type ValidationResult } from '../utils/validation.js';
10
9
  export declare class ProfileService {
11
10
  private queries;
12
11
  constructor(queries: Queries);
@@ -16,7 +15,6 @@ export declare class ProfileService {
16
15
  getCount(): Promise<number>;
17
16
  save(profile: UserProfile): Promise<void>;
18
17
  delete(userId: string): Promise<void>;
19
- validateUsername(username: string): Promise<ValidationResult>;
20
18
  isUsernameTaken(username: string, excludeUserId?: string): Promise<boolean>;
21
19
  createOrUpdate(username: string, userId: string, security: UserProfile['security'], session: Uint8Array): Promise<UserProfile>;
22
20
  }
@@ -5,7 +5,6 @@
5
5
  * Only requires Queries — no session needed, so it can be created at init() time.
6
6
  */
7
7
  import { rowToUserProfile, userProfileToRow, } from '../db/queries/index.js';
8
- import { validateUsernameFormatAndAvailability, } from '../utils/validation.js';
9
8
  export class ProfileService {
10
9
  constructor(queries) {
11
10
  Object.defineProperty(this, "queries", {
@@ -37,9 +36,6 @@ export class ProfileService {
37
36
  delete(userId) {
38
37
  return this.queries.userProfiles.delete(userId);
39
38
  }
40
- validateUsername(username) {
41
- return validateUsernameFormatAndAvailability(username, this.queries);
42
- }
43
39
  async isUsernameTaken(username, excludeUserId) {
44
40
  const match = excludeUserId
45
41
  ? await this.queries.userProfiles.getByUsernameLowerExcluding(username, excludeUserId)
@@ -3,7 +3,6 @@
3
3
  *
4
4
  * Functions for validating user input like usernames, passwords, and user IDs.
5
5
  */
6
- import { Queries } from '../db/queries/index.js';
7
6
  export type ValidationResult = {
8
7
  valid: true;
9
8
  error?: never;
@@ -18,28 +17,13 @@ export type ValidationResult = {
18
17
  * @returns Validation result
19
18
  */
20
19
  export declare function validatePassword(value: string): ValidationResult;
21
- /**
22
- * Validate a username format (without checking availability)
23
- *
24
- * @param value - The username to validate
25
- * @returns Validation result
26
- */
27
- export declare function validateUsernameFormat(value: string): ValidationResult;
28
20
  /**
29
21
  * Validate a username is available (not already in use)
30
22
  *
31
- * @param value - The username to check
32
- * @returns Validation result
33
- */
34
- export declare function validateUsernameAvailability(value: string, queries: Queries): Promise<ValidationResult>;
35
- /**
36
- * Validate a username format and availability
37
- *
38
- * @param value - The username to validate
39
- * @param db - Database instance
40
- * @returns Validation result
41
- */
42
- export declare function validateUsernameFormatAndAvailability(value: string, queries: Queries): Promise<ValidationResult>;
23
+
24
+
25
+
26
+
43
27
  /**
44
28
  * Validate a user ID format (Bech32 gossip1... format)
45
29
  *
@@ -22,72 +22,13 @@ export function validatePassword(value) {
22
22
  }
23
23
  return { valid: true };
24
24
  }
25
- /**
26
- * Validate a username format (without checking availability)
27
- *
28
- * @param value - The username to validate
29
- * @returns Validation result
30
- */
31
- export function validateUsernameFormat(value) {
32
- const trimmed = value.trim();
33
- if (!trimmed) {
34
- return { valid: false, error: 'Username is required' };
35
- }
36
- // Disallow any whitespace inside the username (single token only)
37
- if (/\s/.test(trimmed)) {
38
- return {
39
- valid: false,
40
- error: 'Username cannot contain spaces',
41
- };
42
- }
43
- if (trimmed.length < 3) {
44
- return {
45
- valid: false,
46
- error: 'Username must be at least 3 characters long',
47
- };
48
- }
49
- return { valid: true };
50
- }
51
25
  /**
52
26
  * Validate a username is available (not already in use)
53
27
  *
54
- * @param value - The username to check
55
- * @returns Validation result
56
- */
57
- export async function validateUsernameAvailability(value, queries) {
58
- try {
59
- const existingProfile = await queries.userProfiles.getByUsernameLower(value);
60
- if (existingProfile) {
61
- return {
62
- valid: false,
63
- error: 'This username is already in use. Please choose another.',
64
- };
65
- }
66
- return { valid: true };
67
- }
68
- catch (error) {
69
- return {
70
- valid: false,
71
- error: error instanceof Error
72
- ? error.message
73
- : 'Unable to verify username availability. Please try again.',
74
- };
75
- }
76
- }
77
- /**
78
- * Validate a username format and availability
79
- *
80
- * @param value - The username to validate
81
- * @param db - Database instance
82
- * @returns Validation result
83
- */
84
- export async function validateUsernameFormatAndAvailability(value, queries) {
85
- const result = validateUsernameFormat(value);
86
- if (!result.valid) {
87
- return result;
88
- }
89
- return await validateUsernameAvailability(value, queries);
90
- }
28
+
29
+
30
+
31
+
91
32
  /**
92
33
  * Validate a user ID format (Bech32 gossip1... format)
93
34
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/gossip-sdk",
3
- "version": "0.0.2-dev.20260410095334",
3
+ "version": "0.0.2-dev.20260410113001",
4
4
  "description": "Gossip SDK for automation, chatbot, and integration use cases",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",