@dotrino/identity 0.65.1 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/vault/acta.js +26 -1
package/package.json
CHANGED
package/vault/acta.js
CHANGED
|
@@ -578,6 +578,31 @@ export function memberCanSign (acta, pub, ns = null) {
|
|
|
578
578
|
return ns != null && m.cn === ns
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
+
/**
|
|
582
|
+
* ¿PUEDE ESTE MIEMBRO LO QUE PIDE EL SCOPE? La misma pregunta para todos los mostradores.
|
|
583
|
+
*
|
|
584
|
+
* El certificado dice a qué se comprometió la bóveda cuando conectó el aparato; el ACTA
|
|
585
|
+
* dice lo que puede hoy. Y no coinciden: cambiar los permisos sella el acta pero NO
|
|
586
|
+
* reemite ni revoca el papel, que vive hasta 30 días. Quitarle `lee` a un aparato y que
|
|
587
|
+
* siguiera leyendo un mes es el mismo fallo que estaba en `sign`, en cada mostrador que
|
|
588
|
+
* se olvidara de preguntar.
|
|
589
|
+
*
|
|
590
|
+
* Por eso esto existe y por eso traduce el SCOPE (el idioma del certificado) a la
|
|
591
|
+
* capacidad (el idioma del acta): así el guardia se pone UNA vez, junto a la verificación
|
|
592
|
+
* de la cadena, y un mostrador nuevo lo hereda en lugar de tener que acordarse.
|
|
593
|
+
*
|
|
594
|
+
* Devuelve `false` ante un scope que no reconoce: si aparece uno nuevo, lo que toca es
|
|
595
|
+
* añadirlo aquí, no que se cuele por no estar en la lista.
|
|
596
|
+
*/
|
|
597
|
+
export function memberCanScope (acta, pub, scope) {
|
|
598
|
+
if (!acta || typeof scope !== 'string') return false
|
|
599
|
+
const secretos = /^vault:secrets:([a-z0-9-]{1,32})$/.exec(scope)
|
|
600
|
+
if (secretos) return memberCanReadSecrets(acta, pub, secretos[1])
|
|
601
|
+
if (scope === 'vault:sign') return memberCanSign(acta, pub)
|
|
602
|
+
const cap = Object.keys(CAP_SCOPE).find((c) => CAP_SCOPE[c] === scope)
|
|
603
|
+
return cap ? memberCan(acta, pub, cap) : false
|
|
604
|
+
}
|
|
605
|
+
|
|
581
606
|
export function memberCanReadSecrets (acta, pub, ns) {
|
|
582
607
|
const m = (acta?.members || []).find((x) => x.pub === pub)
|
|
583
608
|
if (!m || !m.cn) return false
|
|
@@ -762,5 +787,5 @@ export default {
|
|
|
762
787
|
sealActa, verifyActa, applyChanges, makeRenounce, verifyRenounce,
|
|
763
788
|
makeContinuity, verifyContinuity,
|
|
764
789
|
cardBody, makeProfileCard, verifyProfileCard, canAdoptCard, sealersOf, canSeal,
|
|
765
|
-
effectiveCaps, memberCan, memberCanSign, memberCanReadSecrets, memberScopes, isService, capScope, isValidCn, canAdopt
|
|
790
|
+
effectiveCaps, memberCan, memberCanSign, memberCanScope, memberCanReadSecrets, memberScopes, isService, capScope, isValidCn, canAdopt
|
|
766
791
|
}
|