From 70e96f171ca607645f62ebf66e2d0a3dead2477c Mon Sep 17 00:00:00 2001 From: balzack Date: Sun, 6 Oct 2024 15:12:36 -0700 Subject: [PATCH] adding registry methods --- app/mobile/src/api/removeContactChannel.js | 11 ++++------- app/sdk/src/contact.ts | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/mobile/src/api/removeContactChannel.js b/app/mobile/src/api/removeContactChannel.js index 8b3d1e61..e304ba85 100644 --- a/app/mobile/src/api/removeContactChannel.js +++ b/app/mobile/src/api/removeContactChannel.js @@ -1,10 +1,7 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil'; -export async function removeContactChannel(server, token, channelId) { - const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server); - const protocol = insecure ? 'http' : 'https'; - - let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}?contact=${token}`, - { method: 'DELETE' }); - checkResponse(channel); +export async function removeContactChannel(node: string, secure: boolean, guid: string, token: string, channelId: string) { + const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}?contact=${guid}.${token}`; + const status = await fetchWithTimeout(endpoint, { method: 'DELETE' }); + checkResponse(status); } diff --git a/app/sdk/src/contact.ts b/app/sdk/src/contact.ts index 511902ac..15ef7990 100644 --- a/app/sdk/src/contact.ts +++ b/app/sdk/src/contact.ts @@ -24,6 +24,8 @@ import { setCardConnected } from "./net/setCardConnected"; import { removeContactChannel } from './net/removeContactChannel'; import { getContactChannelNotifications } from './net/getContactChannelNotifications'; import { setContactChannelNotifications } from './net/setContactChannelNotifications'; +import { getRegistryImageUrl } from './net/getRegistryImageUrl'; +import { getRegistryListing } from './net/getRegistryListing'; const CLOSE_POLL_MS = 100; const RETRY_POLL_MS = 2000; @@ -780,12 +782,20 @@ export class ContactModule implements Contact { } } - public async getRegistry(server: string): Promise { - return []; + public async getRegistry(server: string, secure: boolean): Promise { + const listing = await getRegistryListing(server, secure); + return listing.map(entity => { + const { guid, handle, name, description, location, image, seal, version, node } = entity; + return { + guid, handle, name, description, location, node, version, + sealSet: Boolean(seal), + imageSet: Boolean(image), + }; + }); } - public getRegistryImageUrl(server: string, guid: string): string { - return ""; + public getRegistryImageUrl(server: string, secure: boolean, guid: string): string { + return getRegistryImageUrl(server, secure, guid); } public getCardImageUrl(cardId: string): string {