Exemplo n.º 1
0
    async def addServiceContexted(self,
                                  ipfsop,
                                  service: dict,
                                  endpoint=None,
                                  publish=True,
                                  context='IpfsObjectEndpoint'):
        sid = service.get('id')
        assert isinstance(sid, str)

        didEx = didExplode(sid)
        assert didEx is not None

        if await self.searchServiceById(sid) is not None:
            raise IPIDServiceException(
                'An IP service already exists with this ID')

        srvCtx = await ipfsop.ldContext(context)

        if srvCtx:
            service['serviceEndpoint'] = {'@context': srvCtx}

            if isinstance(endpoint, dict):
                service['serviceEndpoint'].update(endpoint)

            self._document['service'].append(service)
            await self.updateDocument(self.doc, publish=publish)
            await self.sServicesChanged.emit()

            return self._serviceInst(service)
Exemplo n.º 2
0
    def __init__(self, dagNode: dict, ipid):
        self._srv = dagNode
        self._didEx = didExplode(self.id)
        self._ipid = ipid

        self.sChanged = AsyncSignal()
        self.sChanged.connectTo(self.onChanged)
Exemplo n.º 3
0
    def data(self, column, role):
        if column == 0:
            handle = self.peerItem.ctx.spaceHandle
            exploded = didExplode(self.service.id)

            if exploded['path']:
                return posixIpfsPath.join(handle.human,
                                          exploded['path'].lstrip('/'))
        if column == 1:
            return str(self.service.id)

        return QVariant(None)
Exemplo n.º 4
0
    def data(self, column, role):
        if column == 0:
            handle = self.peerItem.ctx.spaceHandle
            exploded = didExplode(self.sObject['id'])

            if exploded and exploded['path']:
                return posixIpfsPath.join(handle.short,
                                          exploded['path'].lstrip('/'))
        if column == 1:
            return self.sObject['id']

        return QVariant(None)
Exemplo n.º 5
0
    async def addServiceRaw(self, service: dict, publish=True):
        sid = service.get('id')
        assert isinstance(sid, str)

        didEx = didExplode(sid)
        assert didEx is not None

        if await self.searchServiceById(sid) is not None:
            raise IPIDServiceException(
                'An IP service already exists with this ID')

        self._document['service'].append(service)
        await self.updateDocument(self.doc, publish=publish)
        await self.sServicesChanged.emit()
Exemplo n.º 6
0
    async def addServiceContexted(self, ipfsop, service: dict,
                                  endpoint=None,
                                  publish=True,
                                  contextInline=False,
                                  context='IpfsObjectEndpoint'):
        sid = service.get('id')
        assert isinstance(sid, str)

        didEx = didExplode(sid)
        assert didEx is not None

        if await self.searchServiceById(sid) is not None:
            raise IPIDServiceException(
                'An IP service already exists with this ID')

        if contextInline is True:
            service['serviceEndpoint'] = {
                '@context': await ipfsop.ldContext(context)
            }
        else:
            service['serviceEndpoint'] = {
                '@context': f'ips://galacteek.ld/{context}',
                '@type': context
            }

        if isinstance(endpoint, dict):
            service['serviceEndpoint'].update(endpoint)

        self._document['service'].append(service)
        await self.updateDocument(self.doc, publish=publish)
        await self.sServicesChanged.emit()

        sInst = self._serviceInst(service)
        await self.servicePropagate(sInst)

        return sInst
Exemplo n.º 7
0
 def ipnsKey(self):
     exploded = didExplode(self.did)
     if exploded and exploded['method'] == 'ipid':
         return exploded['id']
Exemplo n.º 8
0
def ipidExtract(text):
    # Extract the id from "did:ipid:<id>"
    exploded = didExplode(text)
    if exploded:
        return exploded['id']