Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

casbin-basic-adapter

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casbin-basic-adapter - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

test/docker-compose.yml

6

lib/adapter.d.ts

@@ -6,7 +6,8 @@ import type { Adapter, Model } from 'casbin';

import type * as sqlite3 from 'sqlite3';
import type * as mssql from 'mssql';
import * as Knex from 'knex';
export declare type Config = Knex.Config & {
export type Config = Knex.Knex.Config & {
client: keyof Instance;
};
export declare type Instance = {
export type Instance = {
pg: pg.Client;

@@ -16,2 +17,3 @@ mysql: mysql.Connection;

sqlite3: sqlite3.Database;
mssql: mssql.ConnectionPool;
};

@@ -18,0 +20,0 @@ export declare class BasicAdapter<T extends keyof Instance> implements Adapter {

@@ -27,3 +27,2 @@ "use strict";

// import type * as oracledb from 'oracledb';
// import type * as mssql from 'mssql';
const casbin_1 = require("casbin");

@@ -34,4 +33,8 @@ const Knex = require("knex");

constructor(drive, client) {
this.config = { client: drive, useNullAsDefault: drive === 'sqlite3' };
this.knex = Knex(this.config);
this.config = {
client: drive,
useNullAsDefault: drive === 'sqlite3',
log: { warn: () => { } },
};
this.knex = Knex.knex(this.config);
this.drive = drive;

@@ -162,2 +165,6 @@ this.client = client;

}
case 'mssql': {
yield this.client.close();
break;
}
}

@@ -235,2 +242,6 @@ });

}
case 'mssql': {
yield this.client.connect();
break;
}
}

@@ -269,3 +280,9 @@ });

});
break;
}
case 'mssql': {
result = (yield this.client.query(sql))
.recordset;
break;
}
}

@@ -272,0 +289,0 @@ return result !== null && result !== void 0 ? result : [];

@@ -0,0 +0,0 @@ export interface CasbinRule {

@@ -0,0 +0,0 @@ "use strict";

{
"name": "casbin-basic-adapter",
"version": "0.1.0",
"version": "1.0.0",
"description": "A basic adapter supports pg, sqlite3, mysql, mysql2, oracledb and mssql",

@@ -15,32 +15,33 @@ "main": "lib/adapter.js",

"dependencies": {
"knex": "^0.21.1"
"knex": "^2.5.1"
},
"devDependencies": {
"@semantic-release/git": "^9.0.0",
"@types/jest": "^26.0.0",
"@types/mssql": "^6.0.2",
"@types/mysql": "^2.15.14",
"@semantic-release/git": "^10.0.1",
"@types/jest": "^29.5.3",
"@types/mssql": "^8.1.2",
"@types/mysql": "^2.15.21",
"@types/mysql2": "git+https://git@github.com/types/mysql2.git",
"@types/node": "^14.0.13",
"@types/oracledb": "^4.2.2",
"@types/pg": "^7.14.3",
"@types/sqlite3": "^3.1.6",
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"casbin": "^5.1.2",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
"jest": "^26.1.0",
"mssql": "^6.2.0",
"@types/node": "^20.5.0",
"@types/oracledb": "^5.3.0",
"@types/pg": "^8.10.2",
"@types/sqlite3": "^3.1.8",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"casbin": "^5.26.2",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.2",
"mssql": "^9.1.3",
"mysql": "^2.18.1",
"mysql2": "^2.1.0",
"oracledb": "^5.0.0",
"pg": "^8.2.1",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"semantic-release": "^17.1.1",
"sqlite3": "^5.0.0",
"ts-jest": "^26.1.1",
"ts-node": "^8.10.2",
"typescript": "^3.9.6"
"mysql2": "^3.6.0",
"oracledb": "^6.0.3",
"pg": "^8.11.2",
"prettier": "^3.0.1",
"rimraf": "^5.0.1",
"semantic-release": "^21.0.7",
"sqlite3": "^5.1.6",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},

@@ -56,3 +57,2 @@ "peerDependencies": {

"jest": {
"testURL": "http://localhost",
"transform": {

@@ -62,4 +62,7 @@ "^.+\\.(ts|tsx)$": "ts-jest"

"testMatch": [
"**/test/*.+(ts|tsx)"
"**/test/*test.+(ts|tsx)"
],
"testEnvironmentOptions": {
"url": "http://localhost"
},
"moduleFileExtensions": [

@@ -66,0 +69,0 @@ "ts",

# Basic Adapter
[![ci](https://github.com/node-casbin/basic-adapter/actions/workflows/ci.yml/badge.svg)](https://github.com/node-casbin/basic-adapter/actions/workflows/ci.yml)
[![NPM version][npm-image]][npm-url]
[![NPM download][download-image]][download-url]
[![Build Status][ci-image]][ci-url]

@@ -11,10 +11,8 @@ [npm-image]: https://img.shields.io/npm/v/casbin-basic-adapter.svg

[download-url]: https://npmjs.org/package/casbin-basic-adapter
[ci-image]: https://github.com/node-casbin/basic-adapter/workflows/ci/badge.svg?branch=master
[ci-url]: https://github.com/node-casbin/basic-adapter/actions
Basic Adapter is a basic drives adapter for `Node-Casbin` supports `pg`, `sqlite3`, `mysql`, `mysql2`, `oracledb` and `mssql`. With this library, `Node-Casbin` can load policy from supported drives or save policy to it.
Basic Adapter is a basic driver adapter for `Node-Casbin` which supports `pg`, `sqlite3`, `mysql`, `mysql2`, and `mssql`. With this library, `Node-Casbin` can load policy from or save policy to supported persistence systems.
## Drives
we currently supports the following SQL drives:
We currently support the following SQL systems:

@@ -26,3 +24,3 @@ - [x] pg

- [ ] oracledb
- [ ] mssql
- [x] mssql

@@ -29,0 +27,0 @@ ## Installation

@@ -26,5 +26,5 @@ // Copyright 2020 The Casbin Authors. All Rights Reserved.

database: 'casbin',
})
}),
),
60 * 1000
60 * 1000,
);

@@ -26,5 +26,5 @@ // Copyright 2020 The Casbin Authors. All Rights Reserved.

database: 'casbin',
})
}),
),
60 * 1000
60 * 1000,
);

@@ -26,5 +26,5 @@ // Copyright 2020 The Casbin Authors. All Rights Reserved.

password: 'postgres',
})
}),
),
60 * 1000
60 * 1000,
);

@@ -31,3 +31,3 @@ // Copyright 2020 The Casbin Authors. All Rights Reserved.

e: Enforcer,
res: string[][]
res: string[][],
): Promise<void> {

@@ -40,3 +40,3 @@ const myRes = await e.getGroupingPolicy();

drive: T,
client: Instance[T]
client: Instance[T],
) {

@@ -51,3 +51,3 @@ return async function (): Promise<void> {

'examples/rbac_model.conf',
'examples/rbac_policy.csv'
'examples/rbac_policy.csv',
);

@@ -54,0 +54,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc