@startupjs/sharedb-access
Advanced tools
Comparing version 0.56.0-alpha.0 to 0.57.0-canary.0
@@ -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" | ||
} |
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
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
15027
296