Comparing version 0.0.9 to 1.0.0
{ | ||
"name": "auth", | ||
"version": "0.0.9", | ||
"description": "ERROR: No README.md file found!", | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"description": "The CLI tool by Auth.js to supercharge your authentication workflow.", | ||
"homepage": "https://cli.authjs.dev", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"bin": { | ||
"auth": "index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/crcn/node-auth.git" | ||
}, | ||
"author": "", | ||
"license": "BSD", | ||
"files": [ | ||
"*.d.ts*", | ||
"*.js", | ||
"lib", | ||
"src" | ||
], | ||
"keywords": [ | ||
"authjs", | ||
"cli" | ||
], | ||
"author": "Balázs Orbán <info@balazsorban.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"outcome": "0.0.x", | ||
"step": "0.0.x", | ||
"structr": "0.2.x", | ||
"underscore": "1.4.x", | ||
"dsync": "0.0.x", | ||
"vine": "0.1.x", | ||
"dustjs-linkedin": "1.1.x", | ||
"seq": "0.3.x", | ||
"comerr": "0.0.x", | ||
"verify": "0.0.x" | ||
"commander": "11.1.0" | ||
}, | ||
"browserify": "./browser/index.js", | ||
"devDependencies": { | ||
"plugin": "*", | ||
"plugin-express": "0.0.x", | ||
"plugin-mongodb": "0.0.x" | ||
"prettier": { | ||
"semi": false | ||
} | ||
} | ||
} |
181
README.md
@@ -0,175 +1,32 @@ | ||
# Auth.js CLI | ||
The CLI tool by [Auth.js](https://authjs.dev) to supercharge your authentication workflow. | ||
## Features | ||
## Installation | ||
- share items with multiple users | ||
- creating account tokens with access to specific collections & items | ||
- used for locking down public access to certain features. | ||
- ability to add expiration for tokens | ||
- | ||
You don't need to install this package, run any of the following commands: | ||
```javascript | ||
var mongoose = require("mongoose"), | ||
step = require("step"), | ||
Schema = mongoose.Schema, | ||
ObjectId = Schema.Types.ObjectId; | ||
var auth = require("auth").connect({ | ||
connection: mongoose.createConnection("mongodb://localhost/auth-test") | ||
}); | ||
var Post = new Schema({ | ||
message: String | ||
}); | ||
//make the post ownable | ||
Post.plugin(auth.ownable); | ||
step( | ||
function() { | ||
auth.signup({ email: "me@email.com", password: "password" }, this); | ||
}, | ||
function(err, account) { | ||
this.account = account; | ||
var post = new Post({ | ||
message: "Hello World!" | ||
}); | ||
//make the account OWN the post | ||
account.own(post); | ||
post.save(this); | ||
}, | ||
function() { | ||
Post.find(this.account.ownQuery(), this); | ||
}, | ||
function(err, post) { | ||
console.log(post.message); //Hello World! | ||
} | ||
); | ||
```sh | ||
npx auth | ||
``` | ||
## Usage | ||
## auth API | ||
<!-- TODO: Generate by running `node index.js --help` and writing this --> | ||
### auth auth.connect(options) | ||
- options | ||
`connection` - mongodb connection | ||
```sh | ||
Usage: auth [options] [command] | ||
### auth.Account.signup(account, onCreated) | ||
Options: | ||
-V, --version output the version number | ||
-h, --help display help for command | ||
creates a new user | ||
### auth.Account.login(credentals, onLogin) | ||
Logs the user in with u/p, or a token | ||
Example: | ||
```javascript | ||
auth.Account.login({ token: tokenKey }, onLogin); | ||
auth.Account.login({ email: "email", password: "password" }, onLogin); | ||
Commands: | ||
secret [options] Generate a random string. | ||
framework [framework] Clone a framework template. | ||
help [command] display help for command | ||
``` | ||
## Account API | ||
## Acknowledgements | ||
### account.getMainToken(callback) | ||
returns the main access token with super privileges. No restrictions to collections & items. | ||
```javascript | ||
user.getMainToken(function(null, token) { | ||
console.log(token.key); //key used to login | ||
console.log(token.ttl); // -1 = no expiration date. | ||
console.log(token.scope); //[ { collectionName: null, item: null, access: ["GET", "POST", "PUT", "DELETE", "SUPER"]}] | ||
}) | ||
``` | ||
### account.createToken(options, callback) | ||
- `options` - options for the token | ||
- `item` - the item to grant access to (optional) | ||
- `collectionName` - the collection | ||
- `ttl` - time in MS for expiration | ||
- `access` - (array) scope access. default is `access.all()` | ||
```javascript | ||
//only give access to the posts collection, and only allow reading items | ||
user.createToken({ item: Posts.collection.name, access: [access.POST] }, function(err, token) { | ||
console.log(token.scope); //[ { collectionName: "posts", item: null, access: ["GET"]}] | ||
}); | ||
``` | ||
### account.ownItem(item) | ||
makes the account an owner of an item with SUPER privileges on item | ||
```javascript | ||
var p = new Post({ message: "hello!" }); | ||
user.ownItem(p); | ||
p.save(); | ||
``` | ||
### account.shareItem(item, access) | ||
Shares an item with another user | ||
- `item` - item to own | ||
- `access` - access level for the given item. Blank = ALL privileges. | ||
```javascript | ||
var access = require("auth").access; | ||
Post.findOne({message:"hello!"}, function(err, post) { | ||
user2.shareItem(post, [access.GET]); //ability to only see item | ||
post.save(); | ||
}); | ||
``` | ||
### account.authorized(item, access) | ||
returns TRUE if the account has access to the item. Note that the result can be variable | ||
depending if whether the given user logs in with a restricted login token. See below. | ||
```javascript | ||
//logged | ||
user2.authorized(post); //TRUE | ||
user2.authorized(post, [access.POST]); //FALSE | ||
user2.authorized(post, [access.GET]); //TRUE | ||
user2.authorized(post, [access.GET, access.POST]); //TRUE | ||
//login with the post owner, but restrict access with the created | ||
//token above. | ||
User.login({ token: aboveTokenKey }, function(err, user) { | ||
user.authorized(post, [access.TRUE]); //FALSE | ||
user.authorized(post, [access.POST]); //FALSE | ||
}) | ||
``` | ||
### Error account.unauthorized(callback) | ||
Tiny flow-control utility. | ||
### account.addToSearch(query) | ||
adds account to the given search. For example: | ||
```javascript | ||
Post.findOne(user.addToSearch(), function(err, post) { | ||
user.authorized(post); //TRUE | ||
}) | ||
## TODO | ||
- make sub-schemas ownable | ||
- sharing whole collections (job & timer) | ||
- custom authentication schema | ||
- validation of credentials (email/pass) | ||
- Auth.lockdown - prevent models from being saved or serialized if unauthorized | ||
- hooks with [passport](https://github.com/jaredhanson/passport) | ||
Special thanks to Craig for the `auth` package name on npm. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1
0
0
1
0
2
Yes
4574
4
65
33
+ Addedcommander@11.1.0
+ Addedcommander@11.1.0(transitive)
- Removedcomerr@0.0.x
- Removeddsync@0.0.x
- Removeddustjs-linkedin@1.1.x
- Removedoutcome@0.0.x
- Removedseq@0.3.x
- Removedstep@0.0.x
- Removedstructr@0.2.x
- Removedunderscore@1.4.x
- Removedverify@0.0.x
- Removedvine@0.1.x
- Removed@xmldom/xmldom@0.8.10(transitive)
- Removedarray-buffer-byte-length@1.0.2(transitive)
- Removedarraybuffer.prototype.slice@1.0.4(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedchainsaw@0.0.9(transitive)
- Removedcli-table@0.0.2(transitive)
- Removedcoffee-script@1.12.7(transitive)
- Removedcolors@0.3.0(transitive)
- Removedcomerr@0.0.9(transitive)
- Removedcover@0.2.9(transitive)
- Removeddata-view-buffer@1.0.2(transitive)
- Removeddata-view-byte-length@1.0.2(transitive)
- Removeddata-view-byte-offset@1.0.1(transitive)
- Removeddeep-extend@0.2.11(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddref@0.0.6(transitive)
- Removeddsync@0.0.2(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removeddustjs-linkedin@1.1.1(transitive)
- Removedes-abstract@1.23.9(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedes-set-tostringtag@2.1.0(transitive)
- Removedes-to-primitive@1.3.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction.prototype.name@1.1.8(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedget-symbol-description@1.1.0(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-bigints@1.1.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhashish@0.0.4(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinternal-slot@1.1.0(transitive)
- Removedis-array-buffer@3.0.5(transitive)
- Removedis-async-function@2.1.0(transitive)
- Removedis-bigint@1.1.0(transitive)
- Removedis-boolean-object@1.2.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-data-view@1.0.2(transitive)
- Removedis-date-object@1.1.0(transitive)
- Removedis-finalizationregistry@1.1.1(transitive)
- Removedis-generator-function@1.1.0(transitive)
- Removedis-map@2.0.3(transitive)
- Removedis-number-object@1.1.1(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedis-set@2.0.3(transitive)
- Removedis-shared-array-buffer@1.0.4(transitive)
- Removedis-string@1.1.1(transitive)
- Removedis-symbol@1.1.1(transitive)
- Removedis-typed-array@1.1.15(transitive)
- Removedis-weakmap@2.0.2(transitive)
- Removedis-weakref@1.1.0(transitive)
- Removedis-weakset@2.0.4(transitive)
- Removedisarray@2.0.5(transitive)
- Removedjasmine-node@1.0.28(transitive)
- Removedjasmine-reporters@2.5.2(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmkdirp@1.0.4(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.7(transitive)
- Removedoutcome@0.0.18(transitive)
- Removedown-keys@1.0.1(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedreflect.getprototypeof@1.0.10(transitive)
- Removedregexp.prototype.flags@1.5.4(transitive)
- Removedrequirejs@2.3.7(transitive)
- Removedsafe-array-concat@1.1.3(transitive)
- Removedsafe-push-apply@1.0.0(transitive)
- Removedsafe-regex-test@1.1.0(transitive)
- Removedseq@0.3.5(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedset-proto@1.0.0(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedsift@0.0.18(transitive)
- Removedstep@0.0.6(transitive)
- Removedstring.prototype.trim@1.2.10(transitive)
- Removedstring.prototype.trimend@1.0.9(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedstructr@0.2.4(transitive)
- Removedtoarray@0.0.1(transitive)
- Removedtraverse@0.3.90.6.10(transitive)
- Removedtype-component@0.0.1(transitive)
- Removedtyped-array-buffer@1.0.3(transitive)
- Removedtyped-array-byte-length@1.0.3(transitive)
- Removedtyped-array-byte-offset@1.0.4(transitive)
- Removedtyped-array-length@1.0.7(transitive)
- Removedtypedarray.prototype.slice@1.0.5(transitive)
- Removeduglify-js@1.3.3(transitive)
- Removedunbox-primitive@1.1.0(transitive)
- Removedunderscore@1.2.41.4.4(transitive)
- Removedunderscore.string@2.0.0(transitive)
- Removedvalidator@0.4.28(transitive)
- Removedverify@0.0.10(transitive)
- Removedvine@0.1.1(transitive)
- Removedwalkdir@0.4.1(transitive)
- Removedwhich@1.0.9(transitive)
- Removedwhich-boxed-primitive@1.1.1(transitive)
- Removedwhich-builtin-type@1.2.1(transitive)
- Removedwhich-collection@1.0.2(transitive)
- Removedwhich-typed-array@1.1.18(transitive)