File tree Expand file tree Collapse file tree 5 files changed +662
-2
lines changed Expand file tree Collapse file tree 5 files changed +662
-2
lines changed Original file line number Diff line number Diff line change @@ -1790,6 +1790,52 @@ export class RelayManager extends HasLogging {
1790
1790
return relay ;
1791
1791
}
1792
1792
1793
+ async createSelfHostedRelay (
1794
+ url ?: string ,
1795
+ providerId ?: string ,
1796
+ organizationId ?: string ,
1797
+ ) : Promise < Relay > {
1798
+ if ( ! this . pb ) {
1799
+ throw new Error ( "Not connected to relay service" ) ;
1800
+ }
1801
+
1802
+ // Prepare request body - either url for new host or provider for existing
1803
+ const requestBody : {
1804
+ url ?: string ;
1805
+ provider ?: string ;
1806
+ organization ?: string ;
1807
+ } = { } ;
1808
+ if ( providerId ) {
1809
+ requestBody . provider = providerId ;
1810
+ } else if ( url ) {
1811
+ requestBody . url = url ;
1812
+ } else {
1813
+ throw new Error ( "Either URL or provider ID must be provided" ) ;
1814
+ }
1815
+
1816
+ // Add organization if provided
1817
+ if ( organizationId ) {
1818
+ requestBody . organization = organizationId ;
1819
+ }
1820
+
1821
+ // Call the self-host endpoint
1822
+ const response = await this . pb . send ( "/api/collections/relays/self-host" , {
1823
+ method : "POST" ,
1824
+ headers : {
1825
+ "Content-Type" : "application/json" ,
1826
+ } ,
1827
+ body : JSON . stringify ( requestBody ) ,
1828
+ } ) ;
1829
+
1830
+ // Ingest the response into the store
1831
+ const relay = this . store ?. ingest < Relay > ( response ) ;
1832
+ if ( ! relay ) {
1833
+ throw new Error ( "Failed to create self-hosted relay" ) ;
1834
+ }
1835
+
1836
+ return relay ;
1837
+ }
1838
+
1793
1839
async updateRelay ( relay : Relay ) : Promise < Relay > {
1794
1840
if ( ! this . pb ) throw new Error ( "Failed to update relay" ) ;
1795
1841
const record = await this . pb
Original file line number Diff line number Diff line change 765
765
</p >
766
766
{/if }
767
767
{/await }
768
+ {#if relay .provider .publicKey }
769
+ <SettingItem
770
+ name =" Relay Auth Token"
771
+ description =" Copy this key to your Relay Server's TOML configuration."
772
+ >
773
+ <SecretText
774
+ value ={relay .provider .publicKey }
775
+ readonly ={true }
776
+ copyOnClick ={true }
777
+ successMessage =" Public key copied"
778
+ />
779
+ </SettingItem >
780
+ {/if }
768
781
{/if }
769
782
{/if }
770
783
{/if }
You can’t perform that action at this time.
0 commit comments