New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@4a/passcode

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@4a/passcode - npm Package Compare versions

Comparing version
1.0.2
to
2.0.0
+4
.prettierrc
semi: false
singleQuote: true
tabWidth: 4
useTabs: false
declare enum Length {
four = 4,
six = 6
}
export default function generate(length?: Length): string;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Length;
(function (Length) {
Length[Length["four"] = 4] = "four";
Length[Length["six"] = 6] = "six";
})(Length || (Length = {}));
function generate(length = Length.four) {
let i = 0;
let result;
do {
i++;
result = Math.random().toString().slice(2, 2 + length);
} while (result.length !== length && i < 100);
return result;
}
exports.default = generate;
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"target": "es6",
"outDir": "dist",
"strict": true,
"allowJs": true,
"declaration": true
},
"include": ["src/**/*"]
}
+13
-4
{
"name": "@4a/passcode",
"version": "1.0.2",
"version": "2.0.0",
"description": "短信验证码",
"main": "index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "tsc",
"prepublish": "npm run build"
},

@@ -24,3 +26,10 @@ "repository": {

},
"homepage": "https://github.com/gavinning/passcode#readme"
"homepage": "https://github.com/gavinning/passcode#readme",
"devDependencies": {
"@types/node": "^16.3.2",
"typescript": "^4.3.5"
},
"dependencies": {
"ts-node": "^10.1.0"
}
}

@@ -12,3 +12,5 @@ passcode

```js
const passcode = require('@4a/passcode')
import passcode from '@4a/passcode'
// or
const passcode = require('@4a/passcode').default

@@ -23,3 +25,3 @@ console.log(

// 最大支持6位
// 推荐4或6位
console.log(

@@ -26,0 +28,0 @@ passcode(6)

const generate = require('../')
console.log(
generate()
)
function generate(length = 4) {
let i = 0
if (length > 6) {
length = 6
}
let result
do {
i++
result = Math.random().toString().slice(2, 2 + length)
// console.log(i, result)
}
while(result.length !== length && i < 100)
return result
}
module.exports = generate