How To Guides
How to set up access rules based on policies
Each access rule supports attaching policies through the policy property. This property holds the handle of policy that is being reused by the record.
Follow an example of a wallet that attaches two policies to its list of access rules by Ledger SDK.
import { LedgerSdk } from '@minka/ledger-sdk'
const sdk = new LedgerSdk({
    server: '<your ledger URL>',
    signer: {
        format: 'ed25519-raw',
        public: '<your ledger public key>'
    }
})
await sdk.policy.init()
    .data({
        handle: 'wallet-reader',
        record: 'wallet',
        values: [{
            action: 'read',
            bearer: {
                $signer: {
                    $circle: 'bank'
                }
            }
        }]
    })
    .hash()
    .sign([{ keyPair: yourKeyPair }])
    .send()
await sdk.policy.init()
    .data({
        handle: 'wallet-updater',
        record: 'wallet',
        values: [{
            action: 'update',
            signer: {
                $circle: 'bank'
            }
        }]
    })
    .hash()
    .sign([{ keyPair: yourKeyPair }])
    .send()import { LedgerSdk } from '@minka/ledger-sdk'
const sdk = new LedgerSdk({
    server: '<your ledger URL>',
    signer: {
        format: 'ed25519-raw',
        public: '<your ledger public key>'
    }
})
const { wallet } = await sdk.wallet.init()
    .data({
        handle: 'test-wallet',
        access: [{
            policy: 'wallet-reader'
        }, {
            policy: 'wallet-updater' 
        }]
    })
    .hash()
    .sign([{ keyPair: yourKeyPair }])
    .send()Useful Links
- About Security Policies
- About Authorization
- How to set up ledger access rules
- How to set up record access rules