@necto/id 1.2.0 → 1.3.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.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 p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var d=(r,o)=>{for(var t in o)i(r,t,{get:o[t],enumerable:!0})},m=(r,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of g(o))!c.call(r,n)&&n!==t&&i(r,n,{get:()=>o[n],enumerable:!(e=p(o,n))||e.enumerable});return r};var h=(r,o,t)=>(t=r!=null?f(u(r)):{},m(o||!r||!r.__esModule?i(t,"default",{value:r,enumerable:!0}):t,r)),A=r=>m(i({},"__esModule",{value:!0}),r);var E={};d(E,{id:()=>B});module.exports=A(E);var s=h(require("randombytes"),1),a=require("@necto/constants");function B(r=21,o=a.ALPHABET_COMBINED){if(r<=0)throw new Error("Length must be a positive integer.");let t=o.length,e=(0,s.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 * 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_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 = randomBytes(length);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,IAAA,eAAAC,EAAAH,GCQA,IAAAI,EAAwB,4BACxBC,EAAkC,4BAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoB,oBAA2B,CACrF,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 i from"randombytes";import{ALPHABET_COMBINED as m}from"@necto/constants";function f(r=21,o=m){if(r<=0)throw new Error("Length must be a positive integer.");let t=o.length,n=i(r);return Array.from(n).map(e=>o[e%t]).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_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 = randomBytes(length);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"AAQA,OAAOA,MAAiB,cACxB,OAAS,qBAAAC,MAAyB,mBAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoBH,EAA2B,CACrF,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_COMBINED","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.3.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",
@@ -22,8 +22,12 @@
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.14.1",
25
+ "@types/randombytes": "^2.0.3",
25
26
  "tsup": "^8.4.0"
26
27
  },
28
+ "dependencies": {
29
+ "randombytes": "^2.1.0"
30
+ },
27
31
  "scripts": {
28
32
  "build": "tsup --minify",
29
33
  "build:watch": "tsup --watch"