@necto/id 1.2.0 → 1.6.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Necto
3
+ Copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var g=(t,r)=>{for(var n in r)i(t,n,{get:r[n],enumerable:!0})},u=(t,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of p(r))!f.call(t,o)&&o!==n&&i(t,o,{get:()=>r[o],enumerable:!(e=s(r,o))||e.enumerable});return t};var c=t=>u(i({},"__esModule",{value:!0}),t);var A={};g(A,{id:()=>w});module.exports=c(A);var m=require("crypto"),a=require("@necto/constants");function w(t=21,r=a.ALPHABET_COMBINED){if(t<=0)throw new Error("Length must be a positive integer.");let n=r.length,e=new Uint8Array(t);return m.webcrypto.getRandomValues(e),Array.from(e).map(o=>r[o%n]).join("")}0&&(module.exports={id});
1
+ "use strict";var f=Object.create;var i=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var L=(r,o)=>{for(var t in o)i(r,t,{get:o[t],enumerable:!0})},s=(r,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of p(o))!E.call(r,n)&&n!==t&&i(r,n,{get:()=>o[n],enumerable:!(e=A(o,n))||e.enumerable});return r};var u=(r,o,t)=>(t=r!=null?f(g(r)):{},s(o||!r||!r.__esModule?i(t,"default",{value:r,enumerable:!0}):t,r)),c=r=>s(i({},"__esModule",{value:!0}),r);var h={};L(h,{id:()=>d});module.exports=c(h);var a=u(require("randombytes"),1),m=require("@necto/constants");function d(r=21,o=Array.from([...m.ALPHABET.LOWERCASE,...m.ALPHABET.CAPITALIZED])){if(r<=0)throw new Error("Length must be a positive integer.");let t=o.length,e=(0,a.default)(r);return Array.from(e).map(n=>o[n%t]).join("")}0&&(module.exports={id});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport * from \"./id\";","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { webcrypto } from 'node:crypto';\nimport { ALPHABET_COMBINED } from '@necto/constants';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(length: number = 21, charset: string[] = ALPHABET_COMBINED): string {\n if (length <= 0) {\n throw new Error('Length must be a positive integer.');\n }\n\n const charsetLength = charset.length;\n const randomValues = new Uint8Array(length);\n webcrypto.getRandomValues(randomValues);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,IAAA,eAAAC,EAAAH,GCQA,IAAAI,EAA0B,kBAC1BC,EAAkC,4BAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoB,oBAA2B,CACrF,GAAID,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAe,IAAI,WAAWH,CAAM,EAC1C,mBAAU,gBAAgBG,CAAY,EAE/B,MAAM,KAAKA,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["index_exports","__export","id","__toCommonJS","import_node_crypto","import_constants","id","length","charset","charsetLength","randomValues","value"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport * from './id';\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport randomBytes from 'randombytes';\nimport { ALPHABET } from '@necto/constants';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(\n length = 21,\n charset: string[] = Array.from([\n ...ALPHABET.LOWERCASE,\n ...ALPHABET.CAPITALIZED\n ])\n): string {\n if (length <= 0) {\n throw new Error('Length must be a positive integer.');\n }\n\n const charsetLength = charset.length;\n const randomValues = randomBytes(length);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,IAAA,eAAAC,EAAAH,GCQA,IAAAI,EAAwB,4BACxBC,EAAyB,4BAQlB,SAASC,EACdC,EAAS,GACTC,EAAoB,MAAM,KAAK,CAC7B,GAAG,WAAS,UACZ,GAAG,WAAS,WACd,CAAC,EACO,CACR,GAAID,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,KAAe,EAAAC,SAAYJ,CAAM,EAEvC,OAAO,MAAM,KAAKG,CAAY,EAC3B,IAAKE,GAAUJ,EAAQI,EAAQH,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["index_exports","__export","id","__toCommonJS","import_randombytes","import_constants","id","length","charset","charsetLength","randomValues","randomBytes","value"]}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{webcrypto as i}from"node:crypto";import{ALPHABET_COMBINED as m}from"@necto/constants";function p(r=21,t=m){if(r<=0)throw new Error("Length must be a positive integer.");let n=t.length,o=new Uint8Array(r);return i.getRandomValues(o),Array.from(o).map(e=>t[e%n]).join("")}export{p as id};
1
+ import m from"randombytes";import{ALPHABET as t}from"@necto/constants";function f(r=21,o=Array.from([...t.LOWERCASE,...t.CAPITALIZED])){if(r<=0)throw new Error("Length must be a positive integer.");let n=o.length,e=m(r);return Array.from(e).map(i=>o[i%n]).join("")}export{f as id};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { webcrypto } from 'node:crypto';\nimport { ALPHABET_COMBINED } from '@necto/constants';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(length: number = 21, charset: string[] = ALPHABET_COMBINED): string {\n if (length <= 0) {\n throw new Error('Length must be a positive integer.');\n }\n\n const charsetLength = charset.length;\n const randomValues = new Uint8Array(length);\n webcrypto.getRandomValues(randomValues);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"AAQA,OAAS,aAAAA,MAAiB,cAC1B,OAAS,qBAAAC,MAAyB,mBAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoBH,EAA2B,CACrF,GAAIE,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAe,IAAI,WAAWH,CAAM,EAC1C,OAAAH,EAAU,gBAAgBM,CAAY,EAE/B,MAAM,KAAKA,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["webcrypto","ALPHABET_COMBINED","id","length","charset","charsetLength","randomValues","value"]}
1
+ {"version":3,"sources":["../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport randomBytes from 'randombytes';\nimport { ALPHABET } from '@necto/constants';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(\n length = 21,\n charset: string[] = Array.from([\n ...ALPHABET.LOWERCASE,\n ...ALPHABET.CAPITALIZED\n ])\n): string {\n if (length <= 0) {\n throw new Error('Length must be a positive integer.');\n }\n\n const charsetLength = charset.length;\n const randomValues = randomBytes(length);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}\n"],"mappings":"AAQA,OAAOA,MAAiB,cACxB,OAAS,YAAAC,MAAgB,mBAQlB,SAASC,EACdC,EAAS,GACTC,EAAoB,MAAM,KAAK,CAC7B,GAAGH,EAAS,UACZ,GAAGA,EAAS,WACd,CAAC,EACO,CACR,GAAIE,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAeN,EAAYG,CAAM,EAEvC,OAAO,MAAM,KAAKG,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["randomBytes","ALPHABET","id","length","charset","charsetLength","randomValues","value"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necto/id",
3
- "version": "1.2.0",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "description": "Necto's library for generating algorithmic ID's based on specified parameters.",
6
6
  "main": "dist/index.js",
@@ -15,15 +15,17 @@
15
15
  "corinvo",
16
16
  "nectoutil"
17
17
  ],
18
- "peerDependencies": {
19
- "@necto/constants": "1.1.0"
20
- },
21
18
  "author": "Corinvo OSS Team",
22
19
  "license": "MIT",
23
20
  "devDependencies": {
24
21
  "@types/node": "^22.14.1",
22
+ "@types/randombytes": "^2.0.3",
25
23
  "tsup": "^8.4.0"
26
24
  },
25
+ "dependencies": {
26
+ "randombytes": "^2.1.0",
27
+ "@necto/constants": "1.4.0"
28
+ },
27
29
  "scripts": {
28
30
  "build": "tsup --minify",
29
31
  "build:watch": "tsup --watch"
package/dist/index.d.mts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Copyright (c) Corinvo, LLC. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- /**
9
- * Generates a random ID of the specified length using the provided character set.
10
- * @param length - The length of the ID to generate.
11
- * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).
12
- * @returns A randomly generated ID string.
13
- */
14
- declare function id(length?: number, charset?: string[]): string;
15
-
16
- export { id };
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- import{webcrypto as i}from"node:crypto";import{ALPHABET_COMBINED as m}from"@necto/constants";function p(r=21,t=m){if(r<=0)throw new Error("Length must be a positive integer.");let n=t.length,o=new Uint8Array(r);return i.getRandomValues(o),Array.from(o).map(e=>t[e%n]).join("")}export{p as id};
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { webcrypto } from 'node:crypto';\nimport { ALPHABET_COMBINED } from '@necto/constants';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(length: number = 21, charset: string[] = ALPHABET_COMBINED): string {\n if (length <= 0) {\n throw new Error('Length must be a positive integer.');\n }\n\n const charsetLength = charset.length;\n const randomValues = new Uint8Array(length);\n webcrypto.getRandomValues(randomValues);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"AAQA,OAAS,aAAAA,MAAiB,cAC1B,OAAS,qBAAAC,MAAyB,mBAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoBH,EAA2B,CACrF,GAAIE,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAe,IAAI,WAAWH,CAAM,EAC1C,OAAAH,EAAU,gBAAgBM,CAAY,EAE/B,MAAM,KAAKA,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["webcrypto","ALPHABET_COMBINED","id","length","charset","charsetLength","randomValues","value"]}