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

@startupjs/sharedb-access

Package Overview
Dependencies
Maintainers
6
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@startupjs/sharedb-access - npm Package Compare versions

Comparing version 0.56.0-alpha.0 to 0.57.0-canary.0

51

lib/index.js

@@ -34,6 +34,8 @@ import cloneDeep from 'lodash/cloneDeep.js'

backend['allow' + op](collection, (...params) => {
const [,, session] = params
const userId = session.userId
const model = global.__clients[userId].model
return fn(model, collection, ...params)
// TODO: rewrite to use $ here, or create a separate root $ for each user
// const [,, session] = params
// const userId = session.userId
// const model = global.__clients[userId].model
// TODO: first argument was model, it's not needed anymore, or we should pass separate $ for each user
return fn(undefined, collection, ...params)
})

@@ -43,27 +45,28 @@ }

export function rigisterOrmRulesFromFactory (backend, pattern, factory) {
for (const op of operations) {
const collection = pattern.replace(/\.\*$/u, '')
backend['allow' + op](collection, async (...params) => {
const [docId,, session] = params
const userId = session.userId
const model = global.__clients[userId].model
const $doc = model._scope(`${collection}.${docId}`)
// TODO: rewrite to use $ here, or create a separate root $ for each user
// export function registerOrmRulesFromFactory (backend, pattern, factory) {
// for (const op of operations) {
// const collection = pattern.replace(/\.\*$/u, '')
// backend['allow' + op](collection, async (...params) => {
// const [docId,, session] = params
// const userId = session.userId
// const model = global.__clients[userId].model
// const $doc = model._scope(`${collection}.${docId}`)
await $doc.subscribe()
const factoryModel = factory($doc, model)
$doc.unsubscribe()
// await $doc.subscribe()
// const factoryModel = factory($doc, model)
// $doc.unsubscribe()
const access = factoryModel.constructor.access
if (!access) return false
// const access = factoryModel.constructor.access
// if (!access) return false
validateKeys(access, pattern)
// validateKeys(access, pattern)
const opName = op.charAt(0).toLowerCase() + op.slice(1)
const fn = access[opName]
// const opName = op.charAt(0).toLowerCase() + op.slice(1)
// const fn = access[opName]
return fn ? fn(model, collection, ...params) : false
})
}
}
// return fn ? fn(model, collection, ...params) : false
// })
// }
// }

@@ -70,0 +73,0 @@ // Possible options:

{
"name": "@startupjs/sharedb-access",
"version": "0.56.0-alpha.0",
"description": "Sharedb access-control midleware",
"version": "0.57.0-canary.0",
"description": "ShareDB access-control middleware",
"publishConfig": {

@@ -27,5 +27,5 @@ "access": "public"

"racer": "1.0.1",
"sharedb": "^2.0.0"
"sharedb": "^5.0.0"
},
"gitHead": "076772b216a09281ed38b32866b576024562f099"
"gitHead": "0fefd437ff7830800d94d4ed964519a97363ea93"
}
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