File tree 2 files changed +26
-12
lines changed
2 files changed +26
-12
lines changed Original file line number Diff line number Diff line change 1
1
const internalDockerHosts = [ 'localhost:13007' , 'localhost:13000' ] ;
2
2
const externalDockerHosts = [ 'localhost:23007' , 'localhost:23000' ] ;
3
3
4
+ export function getCodespacesBackendUrl ( ) {
5
+ if ( window . location . host . endsWith ( '-13008.app.github.dev' ) ) {
6
+ const arr = window . location . host . split ( '-13008' ) ;
7
+ const codespaceUrl = arr [ 0 ] ;
8
+ return `${ codespaceUrl } -5002.app.github.dev` ;
9
+ }
10
+ return '' ;
11
+ }
12
+
4
13
export function getHost ( ) : string {
5
14
if ( process . env . REACT_APP_LOCAL_ENV ) {
6
15
return 'people-test.sphinx.chat' ;
7
16
}
8
17
9
18
// codespace urls
10
- if ( window . location . host . endsWith ( '-13008.app.github.dev' ) ) {
11
- const arr = window . location . host . split ( '-13008' ) ;
12
- const codespaceUrl = arr [ 0 ] ;
13
- console . log ( `${ codespaceUrl } -5002.app.github.dev` ) ;
14
- return `${ codespaceUrl } -5002.app.github.dev` ;
19
+ const codespaceUrl = getCodespacesBackendUrl ( ) ;
20
+
21
+ if ( codespaceUrl ) {
22
+ return codespaceUrl ;
15
23
}
16
24
17
25
const host = window . location . host . includes ( 'localhost' )
@@ -41,8 +49,5 @@ export const TribesURL = getHost().startsWith('localhost')
41
49
// https://obscure-zebra-94rwjg6r9v37pwg.github.dev/
42
50
43
51
export function isDevHost ( ) {
44
- return (
45
- window . location . host . includes ( 'localhost' ) ||
46
- window . location . host . endsWith ( '-13008.app.github.dev' )
47
- ) ;
52
+ return window . location . host . includes ( 'localhost' ) || ! ! getCodespacesBackendUrl ( ) ;
48
53
}
Original file line number Diff line number Diff line change 1
1
import { bech32 } from 'bech32' ;
2
+ import { getCodespacesBackendUrl } from 'config' ;
2
3
import { ec as EC } from 'elliptic' ;
3
4
4
5
function hexToBytes ( hex : string ) : Uint8Array {
@@ -36,7 +37,15 @@ export async function testUserLnUrlLogin(encode: string) {
36
37
const uint8Array = new Uint8Array ( bech32 . fromWords ( bech32 . decode ( encode , 1500 ) . words ) ) ;
37
38
38
39
const textDecoder = new TextDecoder ( 'utf-8' ) ;
39
- const url = new URL ( textDecoder . decode ( uint8Array ) ) ;
40
+ let rawUrl = textDecoder . decode ( uint8Array ) ;
41
+
42
+ const codespaceUrl = getCodespacesBackendUrl ( ) ;
43
+
44
+ if ( codespaceUrl ) {
45
+ rawUrl = rawUrl . replace ( 'https://app.github.dev' , `https://${ codespaceUrl } ` ) ;
46
+ }
47
+
48
+ const url = new URL ( rawUrl ) ;
40
49
41
50
const message = 'lnurl+cypress+auth' ;
42
51
const hash = await sha256 ( message ) ;
@@ -59,7 +68,7 @@ export async function testUserLnUrlLogin(encode: string) {
59
68
60
69
const response = await fetch ( url . toString ( ) ) ;
61
70
62
- if ( response . ok ) {
63
- console . log ( await response . json ( ) ) ;
71
+ if ( ! response . ok ) {
72
+ console . log ( 'Response from API Call' , response ) ;
64
73
}
65
74
}
You can’t perform that action at this time.
0 commit comments