Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ilya Vysotski
Koa Shopify Auth
Commits
d44f8c06
Commit
d44f8c06
authored
Oct 01, 2020
by
Ilya Vysotski
Browse files
Add the ability to specify the host
parent
d5bff4f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/auth/create-top-level-redirect.ts
View file @
d44f8c06
...
...
@@ -3,10 +3,12 @@ import querystring from 'querystring';
import
{
Context
}
from
'
koa
'
;
import
redirectionPage
from
'
./redirection-page
'
;
import
getHost
from
'
src/lib/get-host
'
;
export
default
function
createTopLevelRedirect
(
apiKey
:
string
,
path
:
string
)
{
return
function
topLevelRedirect
(
ctx
:
Context
)
{
const
{
host
,
query
}
=
ctx
;
const
host
=
getHost
(
ctx
);
const
{
query
}
=
ctx
;
const
{
shop
}
=
query
;
const
params
=
{
shop
};
...
...
src/auth/oauth-query-string.ts
View file @
d44f8c06
...
...
@@ -6,6 +6,7 @@ import nonce from 'nonce';
import
{
OAuthStartOptions
}
from
'
../types
'
;
import
getCookieOptions
from
'
./cookie-options
'
;
import
getHost
from
'
src/lib/get-host
'
;
const
createNonce
=
nonce
();
...
...
@@ -14,7 +15,8 @@ export default function oAuthQueryString(
options
:
OAuthStartOptions
,
callbackPath
:
string
,
)
{
const
{
host
,
cookies
}
=
ctx
;
const
host
=
getHost
(
ctx
);
const
{
cookies
}
=
ctx
;
const
{
scopes
=
[],
apiKey
,
accessMode
}
=
options
;
const
requestNonce
=
createNonce
();
...
...
src/lib/get-host.ts
0 → 100644
View file @
d44f8c06
import
{
Context
}
from
'
koa
'
;
export
default
function
getHost
(
ctx
:
Context
)
{
console
.
log
({
koaShopifyAuthEnv
:
process
.
env
});
const
{
SHOPIFY_APP_HOST
}
=
process
.
env
;
return
SHOPIFY_APP_HOST
||
ctx
.
host
;
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment