@shopify/shopify-app-remix 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/build/cjs/react/components/AppProvider/AppProvider.js +35 -4
- package/build/cjs/server/authenticate/admin/billing/request.js +4 -2
- package/build/cjs/server/authenticate/public/appProxy/authenticate.js +7 -1
- package/build/cjs/server/boundary/index.js +6 -6
- package/build/cjs/server/clients/storefront/factory.js +35 -0
- package/build/cjs/server/shopify-app.js +7 -5
- package/build/cjs/server/types.js +1 -1
- package/build/cjs/server/unauthenticated/admin/factory.js +2 -2
- package/build/cjs/server/unauthenticated/helpers/get-offline-session.js +14 -0
- package/build/cjs/server/unauthenticated/storefront/factory.js +25 -0
- package/build/cjs/server/version.js +1 -1
- package/build/ts/react/components/AppProvider/AppProvider.d.ts +48 -8
- package/build/ts/react/components/AppProvider/AppProvider.d.ts.map +1 -1
- package/build/ts/react/components/AppProvider/AppProvider.doc.d.ts +4 -0
- package/build/ts/react/components/AppProvider/AppProvider.doc.d.ts.map +1 -0
- package/build/ts/react/components/AppProvider/AppProvider.doc.js +34 -0
- package/build/ts/react/components/AppProvider/AppProvider.doc.js.map +1 -0
- package/build/ts/react/components/AppProvider/AppProvider.js +35 -3
- package/build/ts/react/components/AppProvider/AppProvider.js.map +1 -1
- package/build/ts/server/__test-helpers/expect-admin-api-client.d.ts +1 -1
- package/build/ts/server/__test-helpers/expect-admin-api-client.d.ts.map +1 -1
- package/build/ts/server/__test-helpers/expect-storefront-api-client.d.ts +8 -0
- package/build/ts/server/__test-helpers/expect-storefront-api-client.d.ts.map +1 -0
- package/build/ts/server/__test-helpers/expect-storefront-api-client.js +57 -0
- package/build/ts/server/__test-helpers/expect-storefront-api-client.js.map +1 -0
- package/build/ts/server/__test-helpers/index.d.ts +1 -0
- package/build/ts/server/__test-helpers/index.d.ts.map +1 -1
- package/build/ts/server/__test-helpers/index.js +1 -0
- package/build/ts/server/__test-helpers/index.js.map +1 -1
- package/build/ts/server/authenticate/admin/authenticate.admin.doc.d.ts +4 -0
- package/build/ts/server/authenticate/admin/authenticate.admin.doc.d.ts.map +1 -0
- package/build/ts/server/authenticate/admin/authenticate.admin.doc.js +35 -0
- package/build/ts/server/authenticate/admin/authenticate.admin.doc.js.map +1 -0
- package/build/ts/server/authenticate/admin/authenticate.d.ts.map +1 -1
- package/build/ts/server/authenticate/admin/authenticate.js.map +1 -1
- package/build/ts/server/authenticate/admin/billing/authenticate.admin.billing.doc.d.ts +4 -0
- package/build/ts/server/authenticate/admin/billing/authenticate.admin.billing.doc.d.ts.map +1 -0
- package/build/ts/server/authenticate/admin/billing/authenticate.admin.billing.doc.js +26 -0
- package/build/ts/server/authenticate/admin/billing/authenticate.admin.billing.doc.js.map +1 -0
- package/build/ts/server/authenticate/admin/billing/request.d.ts +1 -1
- package/build/ts/server/authenticate/admin/billing/request.d.ts.map +1 -1
- package/build/ts/server/authenticate/admin/billing/request.js +2 -8
- package/build/ts/server/authenticate/admin/billing/request.js.map +1 -1
- package/build/ts/server/authenticate/admin/billing/types.d.ts +63 -55
- package/build/ts/server/authenticate/admin/billing/types.d.ts.map +1 -1
- package/build/ts/server/authenticate/admin/types.d.ts +66 -30
- package/build/ts/server/authenticate/admin/types.d.ts.map +1 -1
- package/build/ts/server/authenticate/helpers/add-response-headers.d.ts +2 -1
- package/build/ts/server/authenticate/helpers/add-response-headers.d.ts.map +1 -1
- package/build/ts/server/authenticate/helpers/add-response-headers.js.map +1 -1
- package/build/ts/server/authenticate/public/appProxy/authenticate.d.ts.map +1 -1
- package/build/ts/server/authenticate/public/appProxy/authenticate.js +4 -2
- package/build/ts/server/authenticate/public/appProxy/authenticate.js.map +1 -1
- package/build/ts/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.d.ts +4 -0
- package/build/ts/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.d.ts.map +1 -0
- package/build/ts/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.js +32 -0
- package/build/ts/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.js.map +1 -0
- package/build/ts/server/authenticate/public/appProxy/types.d.ts +64 -8
- package/build/ts/server/authenticate/public/appProxy/types.d.ts.map +1 -1
- package/build/ts/server/authenticate/public/checkout/authenticate.public.checkout.doc.d.ts +4 -0
- package/build/ts/server/authenticate/public/checkout/authenticate.public.checkout.doc.d.ts.map +1 -0
- package/build/ts/server/authenticate/public/checkout/authenticate.public.checkout.doc.js +21 -0
- package/build/ts/server/authenticate/public/checkout/authenticate.public.checkout.doc.js.map +1 -0
- package/build/ts/server/authenticate/public/checkout/types.d.ts +15 -13
- package/build/ts/server/authenticate/public/checkout/types.d.ts.map +1 -1
- package/build/ts/server/authenticate/public/types.d.ts +19 -17
- package/build/ts/server/authenticate/public/types.d.ts.map +1 -1
- package/build/ts/server/authenticate/webhooks/authenticate.webhooks.doc.d.ts +4 -0
- package/build/ts/server/authenticate/webhooks/authenticate.webhooks.doc.d.ts.map +1 -0
- package/build/ts/server/authenticate/webhooks/authenticate.webhooks.doc.js +20 -0
- package/build/ts/server/authenticate/webhooks/authenticate.webhooks.doc.js.map +1 -0
- package/build/ts/server/authenticate/webhooks/types.d.ts +103 -0
- package/build/ts/server/authenticate/webhooks/types.d.ts.map +1 -1
- package/build/ts/server/boundary/index.d.ts +6 -6
- package/build/ts/server/boundary/index.js +6 -6
- package/build/ts/server/clients/admin/authenticate.admin.api.doc.d.ts +4 -0
- package/build/ts/server/clients/admin/authenticate.admin.api.doc.d.ts.map +1 -0
- package/build/ts/server/clients/admin/authenticate.admin.api.doc.js +32 -0
- package/build/ts/server/clients/admin/authenticate.admin.api.doc.js.map +1 -0
- package/build/ts/server/clients/admin/factory.d.ts +1 -1
- package/build/ts/server/clients/admin/factory.d.ts.map +1 -1
- package/build/ts/server/clients/admin/factory.js.map +1 -1
- package/build/ts/server/clients/admin/graphql.d.ts +3 -15
- package/build/ts/server/clients/admin/graphql.d.ts.map +1 -1
- package/build/ts/server/clients/admin/graphql.js.map +1 -1
- package/build/ts/server/clients/admin/index.d.ts +1 -0
- package/build/ts/server/clients/admin/index.d.ts.map +1 -1
- package/build/ts/server/clients/admin/index.js +1 -0
- package/build/ts/server/clients/admin/index.js.map +1 -1
- package/build/ts/server/clients/admin/rest.d.ts +1 -1
- package/build/ts/server/clients/admin/rest.d.ts.map +1 -1
- package/build/ts/server/clients/admin/types.d.ts +105 -1
- package/build/ts/server/clients/admin/types.d.ts.map +1 -1
- package/build/ts/server/clients/index.d.ts +3 -0
- package/build/ts/server/clients/index.d.ts.map +1 -0
- package/build/ts/server/clients/index.js +6 -0
- package/build/ts/server/clients/index.js.map +1 -0
- package/build/ts/server/clients/storefront/authenticate.storefront.api.doc.d.ts +4 -0
- package/build/ts/server/clients/storefront/authenticate.storefront.api.doc.d.ts.map +1 -0
- package/build/ts/server/clients/storefront/authenticate.storefront.api.doc.js +32 -0
- package/build/ts/server/clients/storefront/authenticate.storefront.api.doc.js.map +1 -0
- package/build/ts/server/clients/storefront/factory.d.ts +8 -0
- package/build/ts/server/clients/storefront/factory.d.ts.map +1 -0
- package/build/ts/server/clients/storefront/factory.js +39 -0
- package/build/ts/server/clients/storefront/factory.js.map +1 -0
- package/build/ts/server/clients/storefront/index.d.ts +3 -0
- package/build/ts/server/clients/storefront/index.d.ts.map +1 -0
- package/build/ts/server/clients/storefront/index.js +6 -0
- package/build/ts/server/clients/storefront/index.js.map +1 -0
- package/build/ts/server/clients/storefront/types.d.ts +29 -0
- package/build/ts/server/clients/storefront/types.d.ts.map +1 -0
- package/build/ts/server/clients/storefront/types.js +3 -0
- package/build/ts/server/clients/storefront/types.js.map +1 -0
- package/build/ts/server/clients/types.d.ts +15 -0
- package/build/ts/server/clients/types.d.ts.map +1 -0
- package/build/ts/server/clients/types.js +3 -0
- package/build/ts/server/clients/types.js.map +1 -0
- package/build/ts/server/config-types.d.ts +26 -117
- package/build/ts/server/config-types.d.ts.map +1 -1
- package/build/ts/server/shopify-app.d.ts +3 -3
- package/build/ts/server/shopify-app.d.ts.map +1 -1
- package/build/ts/server/shopify-app.doc.d.ts +4 -0
- package/build/ts/server/shopify-app.doc.d.ts.map +1 -0
- package/build/ts/server/shopify-app.doc.js +36 -0
- package/build/ts/server/shopify-app.doc.js.map +1 -0
- package/build/ts/server/shopify-app.js +6 -4
- package/build/ts/server/shopify-app.js.map +1 -1
- package/build/ts/server/types.d.ts +200 -168
- package/build/ts/server/types.d.ts.map +1 -1
- package/build/ts/server/types.js.map +1 -1
- package/build/ts/server/unauthenticated/admin/factory.d.ts.map +1 -1
- package/build/ts/server/unauthenticated/admin/factory.js +3 -4
- package/build/ts/server/unauthenticated/admin/factory.js.map +1 -1
- package/build/ts/server/unauthenticated/admin/types.d.ts +9 -7
- package/build/ts/server/unauthenticated/admin/types.d.ts.map +1 -1
- package/build/ts/server/unauthenticated/admin/unauthenticated.admin.doc.d.ts +4 -0
- package/build/ts/server/unauthenticated/admin/unauthenticated.admin.doc.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/admin/unauthenticated.admin.doc.js +29 -0
- package/build/ts/server/unauthenticated/admin/unauthenticated.admin.doc.js.map +1 -0
- package/build/ts/server/unauthenticated/helpers/get-offline-session.d.ts +4 -0
- package/build/ts/server/unauthenticated/helpers/get-offline-session.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/helpers/get-offline-session.js +22 -0
- package/build/ts/server/unauthenticated/helpers/get-offline-session.js.map +1 -0
- package/build/ts/server/unauthenticated/helpers/index.d.ts +2 -0
- package/build/ts/server/unauthenticated/helpers/index.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/helpers/index.js +5 -0
- package/build/ts/server/unauthenticated/helpers/index.js.map +1 -0
- package/build/ts/server/unauthenticated/storefront/factory.d.ts +4 -0
- package/build/ts/server/unauthenticated/storefront/factory.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/storefront/factory.js +29 -0
- package/build/ts/server/unauthenticated/storefront/factory.js.map +1 -0
- package/build/ts/server/unauthenticated/storefront/index.d.ts +2 -0
- package/build/ts/server/unauthenticated/storefront/index.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/storefront/index.js +5 -0
- package/build/ts/server/unauthenticated/storefront/index.js.map +1 -0
- package/build/ts/server/unauthenticated/storefront/types.d.ts +34 -0
- package/build/ts/server/unauthenticated/storefront/types.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/storefront/types.js +3 -0
- package/build/ts/server/unauthenticated/storefront/types.js.map +1 -0
- package/build/ts/server/unauthenticated/storefront/unauthenticated.storefront.doc.d.ts +4 -0
- package/build/ts/server/unauthenticated/storefront/unauthenticated.storefront.doc.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/storefront/unauthenticated.storefront.doc.js +29 -0
- package/build/ts/server/unauthenticated/storefront/unauthenticated.storefront.doc.js.map +1 -0
- package/build/ts/server/unauthenticated/types.d.ts +66 -0
- package/build/ts/server/unauthenticated/types.d.ts.map +1 -0
- package/build/ts/server/unauthenticated/types.js +3 -0
- package/build/ts/server/unauthenticated/types.js.map +1 -0
- package/build/ts/server/version.d.ts +1 -1
- package/build/ts/server/version.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JwtPayload, Session, ShopifyRestResources } from '@shopify/shopify-api';
|
|
2
2
|
import { EnsureCORSFunction } from '../helpers/ensure-cors-headers';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AppConfigArg } from '../../config-types';
|
|
4
|
+
import type { AdminApiContext } from '../../clients';
|
|
4
5
|
import type { BillingContext } from './billing/types';
|
|
5
6
|
import { RedirectFunction } from './helpers/redirect';
|
|
6
7
|
interface AdminContextInternal<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> {
|
|
@@ -9,27 +10,39 @@ interface AdminContextInternal<Config extends AppConfigArg, Resources extends Sh
|
|
|
9
10
|
*
|
|
10
11
|
* This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice.
|
|
11
12
|
*
|
|
12
|
-
* Use this to get shop or user
|
|
13
|
+
* Use this to get shop or user-specific data.
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
|
-
*
|
|
16
|
+
* <caption>Using offline sessions.</caption>
|
|
17
|
+
* <description>Get your app's shop-specific data using an offline session.</description>
|
|
16
18
|
* ```ts
|
|
17
|
-
* //
|
|
19
|
+
* // shopify.server.ts
|
|
20
|
+
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
|
|
21
|
+
*
|
|
22
|
+
* const shopify = shopifyApp({
|
|
23
|
+
* // ...etc
|
|
24
|
+
* });
|
|
25
|
+
* export default shopify;
|
|
26
|
+
* export const authenticate = shopify.authenticate;
|
|
27
|
+
* ```
|
|
28
|
+
* ```ts
|
|
29
|
+
* // /app/routes/**\/*.ts
|
|
18
30
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
19
31
|
* import { authenticate } from "../shopify.server";
|
|
20
|
-
* import {
|
|
32
|
+
* import { getMyAppData } from "~/db/model.server";
|
|
21
33
|
*
|
|
22
34
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
23
35
|
* const { session } = await authenticate.admin(request);
|
|
24
|
-
* return json(await
|
|
36
|
+
* return json(await getMyAppData({shop: session.shop));
|
|
25
37
|
* };
|
|
26
38
|
* ```
|
|
27
39
|
*
|
|
28
40
|
* @example
|
|
29
|
-
*
|
|
41
|
+
* <caption>Using online sessions.</caption>
|
|
42
|
+
* <description>Get your app's user-specific data using an online session.</description>
|
|
30
43
|
* ```ts
|
|
31
44
|
* // shopify.server.ts
|
|
32
|
-
* import { shopifyApp } from "@shopify/shopify-app-remix";
|
|
45
|
+
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
|
|
33
46
|
*
|
|
34
47
|
* const shopify = shopifyApp({
|
|
35
48
|
* // ...etc
|
|
@@ -37,21 +50,22 @@ interface AdminContextInternal<Config extends AppConfigArg, Resources extends Sh
|
|
|
37
50
|
* });
|
|
38
51
|
* export default shopify;
|
|
39
52
|
* export const authenticate = shopify.authenticate;
|
|
40
|
-
*
|
|
41
|
-
*
|
|
53
|
+
* ```
|
|
54
|
+
* ```ts
|
|
55
|
+
* // /app/routes/**\/*.ts
|
|
42
56
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
43
57
|
* import { authenticate } from "../shopify.server";
|
|
44
|
-
* import {
|
|
58
|
+
* import { getMyAppData } from "~/db/model.server";
|
|
45
59
|
*
|
|
46
60
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
47
61
|
* const { session } = await authenticate.admin(request);
|
|
48
|
-
* return json(await
|
|
62
|
+
* return json(await getMyAppData({user: session.onlineAccessInfo!.id}));
|
|
49
63
|
* };
|
|
50
64
|
* ```
|
|
51
65
|
*/
|
|
52
66
|
session: Session;
|
|
53
67
|
/**
|
|
54
|
-
* Methods for interacting with the
|
|
68
|
+
* Methods for interacting with the GraphQL / REST Admin APIs for the store that made the request.
|
|
55
69
|
*/
|
|
56
70
|
admin: AdminApiContext<Resources>;
|
|
57
71
|
/**
|
|
@@ -61,19 +75,20 @@ interface AdminContextInternal<Config extends AppConfigArg, Resources extends Sh
|
|
|
61
75
|
*/
|
|
62
76
|
billing: BillingContext<Config>;
|
|
63
77
|
/**
|
|
64
|
-
* A function that ensures the CORS headers are set correctly for the response
|
|
78
|
+
* A function that ensures the CORS headers are set correctly for the response.
|
|
65
79
|
*
|
|
66
80
|
* @example
|
|
67
|
-
* Setting CORS headers for a admin request
|
|
81
|
+
* <caption>Setting CORS headers for a admin request.</caption>
|
|
82
|
+
* <description>Use the `cors` helper to ensure your app can respond to requests from admin extensions.</description>
|
|
68
83
|
* ```ts
|
|
69
|
-
* // app/routes/admin/
|
|
84
|
+
* // /app/routes/admin/my-route.ts
|
|
70
85
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
71
86
|
* import { authenticate } from "../shopify.server";
|
|
72
|
-
* import {
|
|
87
|
+
* import { getMyAppData } from "~/db/model.server";
|
|
73
88
|
*
|
|
74
89
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
75
90
|
* const { session, cors } = await authenticate.admin(request);
|
|
76
|
-
* return cors(json(await
|
|
91
|
+
* return cors(json(await getMyAppData({user: session.onlineAccessInfo!.id})));
|
|
77
92
|
* };
|
|
78
93
|
* ```
|
|
79
94
|
*/
|
|
@@ -81,15 +96,18 @@ interface AdminContextInternal<Config extends AppConfigArg, Resources extends Sh
|
|
|
81
96
|
}
|
|
82
97
|
export interface EmbeddedAdminContext<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> extends AdminContextInternal<Config, Resources> {
|
|
83
98
|
/**
|
|
84
|
-
* The decoded and validated session token for the request
|
|
99
|
+
* The decoded and validated session token for the request.
|
|
100
|
+
*
|
|
101
|
+
* Returned only if `isEmbeddedApp` is `true`.
|
|
85
102
|
*
|
|
86
103
|
* {@link https://shopify.dev/docs/apps/auth/oauth/session-tokens#payload}
|
|
87
104
|
*
|
|
88
105
|
* @example
|
|
89
|
-
*
|
|
106
|
+
* <caption>Using the decoded session token.</caption>
|
|
107
|
+
* <description>Get user-specific data using the `sessionToken` object.</description>
|
|
90
108
|
* ```ts
|
|
91
109
|
* // shopify.server.ts
|
|
92
|
-
* import { shopifyApp } from "@shopify/shopify-app-remix";
|
|
110
|
+
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
|
|
93
111
|
*
|
|
94
112
|
* const shopify = shopifyApp({
|
|
95
113
|
* // ...etc
|
|
@@ -97,43 +115,61 @@ export interface EmbeddedAdminContext<Config extends AppConfigArg, Resources ext
|
|
|
97
115
|
* });
|
|
98
116
|
* export default shopify;
|
|
99
117
|
* export const authenticate = shopify.authenticate;
|
|
100
|
-
*
|
|
101
|
-
*
|
|
118
|
+
* ```
|
|
119
|
+
* ```ts
|
|
120
|
+
* // /app/routes/**\/*.ts
|
|
102
121
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
103
122
|
* import { authenticate } from "../shopify.server";
|
|
104
|
-
* import {
|
|
123
|
+
* import { getMyAppData } from "~/db/model.server";
|
|
105
124
|
*
|
|
106
125
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
107
|
-
* const { sessionToken } = await authenticate.public(
|
|
126
|
+
* const { sessionToken } = await authenticate.public.checkout(
|
|
108
127
|
* request
|
|
109
128
|
* );
|
|
110
|
-
* return json(await
|
|
129
|
+
* return json(await getMyAppData({user: sessionToken.sub}));
|
|
111
130
|
* };
|
|
112
131
|
* ```
|
|
113
132
|
*/
|
|
114
133
|
sessionToken: JwtPayload;
|
|
115
134
|
/**
|
|
116
135
|
* A function that redirects the user to a new page, ensuring that the appropriate parameters are set for embedded
|
|
117
|
-
* apps
|
|
136
|
+
* apps.
|
|
137
|
+
*
|
|
138
|
+
* Returned only if `isEmbeddedApp` is `true`.
|
|
118
139
|
*
|
|
119
140
|
* @example
|
|
120
|
-
* Redirecting
|
|
141
|
+
* <caption>Redirecting to an app route.</caption>
|
|
142
|
+
* <description>Use the `redirect` helper to safely redirect between pages.</description>
|
|
121
143
|
* ```ts
|
|
122
|
-
* // app/routes/admin/
|
|
144
|
+
* // /app/routes/admin/my-route.ts
|
|
123
145
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
124
146
|
* import { authenticate } from "../shopify.server";
|
|
125
|
-
* import { getWidgets } from "~/db/widgets.server";
|
|
126
147
|
*
|
|
127
148
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
128
149
|
* const { session, redirect } = await authenticate.admin(request);
|
|
129
150
|
* return redirect("/");
|
|
130
151
|
* };
|
|
131
152
|
* ```
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* <caption>Redirecting outside of Shopify admin.</caption>
|
|
156
|
+
* <description>Pass in a `target` option of `_top` or `_parent` to go to an external URL.</description>
|
|
157
|
+
* ```ts
|
|
158
|
+
* // /app/routes/admin/my-route.ts
|
|
159
|
+
* import { LoaderArgs, json } from "@remix-run/node";
|
|
160
|
+
* import { authenticate } from "../shopify.server";
|
|
161
|
+
*
|
|
162
|
+
* export const loader = async ({ request }: LoaderArgs) => {
|
|
163
|
+
* const { session, redirect } = await authenticate.admin(request);
|
|
164
|
+
* return redirect("/", { target: '_parent' });
|
|
165
|
+
* };
|
|
166
|
+
* ```
|
|
132
167
|
*/
|
|
133
168
|
redirect: RedirectFunction;
|
|
134
169
|
}
|
|
135
170
|
export interface NonEmbeddedAdminContext<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> extends AdminContextInternal<Config, Resources> {
|
|
136
171
|
}
|
|
137
172
|
export type AdminContext<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> = Config['isEmbeddedApp'] extends false ? NonEmbeddedAdminContext<Config, Resources> : EmbeddedAdminContext<Config, Resources>;
|
|
173
|
+
export type AuthenticateAdmin<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> = (request: Request) => Promise<AdminContext<Config, Resources>>;
|
|
138
174
|
export {};
|
|
139
175
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/admin/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,OAAO,EAAE,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/admin/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,OAAO,EAAE,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEpD,UAAU,oBAAoB,CAC5B,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB;IAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyDG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAElC;;;;OAIG;IACH,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAEhC;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB,CACnC,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,CAC7D,SAAQ,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC;IAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,YAAY,EAAE,UAAU,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AACD,MAAM,WAAW,uBAAuB,CACtC,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,CAC7D,SAAQ,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC;CAAG;AAEpD,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,IAC3D,MAAM,CAAC,eAAe,CAAC,SAAS,KAAK,GACrC,uBAAuB,CAAC,MAAM,EAAE,SAAS,CAAC,GAC1C,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE5C,MAAM,MAAM,iBAAiB,CAC3B,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,IAC3D,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BasicParams } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type AddDocumentResponseHeadersFunction = (request: Request, headers: Headers) => void;
|
|
3
|
+
export declare function addDocumentResponseHeadersFactory(params: BasicParams): AddDocumentResponseHeadersFunction;
|
|
3
4
|
export declare function addDocumentResponseHeaders(headers: Headers, isEmbeddedApp: boolean, shop: string | null | undefined): void;
|
|
4
5
|
//# sourceMappingURL=add-response-headers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-response-headers.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/helpers/add-response-headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAE7C,
|
|
1
|
+
{"version":3,"file":"add-response-headers.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/helpers/add-response-headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,kCAAkC,GAAG,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,KACb,IAAI,CAAC;AAEV,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,WAAW,GAClB,kCAAkC,CASpC;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,QAmBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-response-headers.js","sourceRoot":"","sources":["../../../../../src/server/authenticate/helpers/add-response-headers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"add-response-headers.js","sourceRoot":"","sources":["../../../../../src/server/authenticate/helpers/add-response-headers.ts"],"names":[],"mappings":";;;AAOA,SAAgB,iCAAiC,CAC/C,MAAmB;IAEZ,IAAA,GAAG,GAAY,MAAM,IAAlB,EAAE,MAAM,GAAI,MAAM,OAAV,CAAW;IAE7B,OAAO,UAAU,OAAgB,EAAE,OAAgB;QAC1C,IAAA,YAAY,GAAI,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAxB,CAAyB;QAC5C,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,CAAC;QAE/D,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AAXD,8EAWC;AAED,SAAgB,0BAA0B,CACxC,OAAgB,EAChB,aAAsB,EACtB,IAA+B;IAE/B,IAAI,IAAI,EAAE;QACR,OAAO,CAAC,GAAG,CACT,MAAM,EACN,mFAAmF,CACpF,CAAC;KACH;IAED,IAAI,aAAa,EAAE;QACjB,IAAI,IAAI,EAAE;YACR,OAAO,CAAC,GAAG,CACT,yBAAyB,EACzB,kCAA2B,IAAI,mDAAgD,CAChF,CAAC;SACH;KACF;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,yBAAyB,CAAC,CAAC;KACnE;AACH,CAAC;AAtBD,gEAsBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/authenticate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAGL,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,2BAA2B,CACzC,SAAS,SAAS,oBAAoB,EACtC,MAAM,EAAE,WAAW,GAAG,oBAAoB,
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/authenticate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAGL,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,2BAA2B,CACzC,SAAS,SAAS,oBAAoB,EACtC,MAAM,EAAE,WAAW,GAAG,oBAAoB,CAqD3C"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.authenticateAppProxyFactory = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var
|
|
5
|
+
var clients_1 = require("../../../clients");
|
|
6
6
|
function authenticateAppProxyFactory(params) {
|
|
7
7
|
var api = params.api, config = params.config, logger = params.logger;
|
|
8
8
|
return function authenticate(request) {
|
|
@@ -46,13 +46,15 @@ function authenticateAppProxyFactory(params) {
|
|
|
46
46
|
liquid: liquid,
|
|
47
47
|
session: undefined,
|
|
48
48
|
admin: undefined,
|
|
49
|
+
storefront: undefined,
|
|
49
50
|
};
|
|
50
51
|
return [2 /*return*/, context_1];
|
|
51
52
|
}
|
|
52
53
|
context = {
|
|
53
54
|
liquid: liquid,
|
|
54
55
|
session: session,
|
|
55
|
-
admin: (0,
|
|
56
|
+
admin: (0, clients_1.adminClientFactory)({ params: params, session: session }),
|
|
57
|
+
storefront: (0, clients_1.storefrontClientFactory)({ params: params, session: session }),
|
|
56
58
|
};
|
|
57
59
|
return [2 /*return*/, context];
|
|
58
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/authenticate.ts"],"names":[],"mappings":";;;;AAEA,
|
|
1
|
+
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/authenticate.ts"],"names":[],"mappings":"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"}
|
package/build/ts/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.public.app-proxy.doc.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,6BA4BX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var data = {
|
|
4
|
+
name: 'App proxy',
|
|
5
|
+
description: 'The `authenticate.public.appProxy` function validates app proxy requests made by Shopify, and returns a context to enable querying Shopify APIs.',
|
|
6
|
+
category: 'Authenticate',
|
|
7
|
+
subCategory: 'Public',
|
|
8
|
+
type: 'object',
|
|
9
|
+
isVisualComponent: false,
|
|
10
|
+
definitions: [
|
|
11
|
+
{
|
|
12
|
+
title: 'authenticate.public.appProxy',
|
|
13
|
+
description: 'Authenticates requests coming from Shopify app proxies.',
|
|
14
|
+
type: 'AuthenticateAppProxy',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
jsDocTypeExamples: ['AppProxyContextWithSession'],
|
|
18
|
+
related: [
|
|
19
|
+
{
|
|
20
|
+
name: 'Admin API context',
|
|
21
|
+
subtitle: 'Interact with the Admin API.',
|
|
22
|
+
url: '/docs/api/shopify-app-remix/apis/admin-api',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Storefront API context',
|
|
26
|
+
subtitle: 'Interact with the Storefront API.',
|
|
27
|
+
url: '/docs/api/shopify-app-remix/apis/storefront-api',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
exports.default = data;
|
|
32
|
+
//# sourceMappingURL=authenticate.public.app-proxy.doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.public.app-proxy.doc.js","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.ts"],"names":[],"mappings":";;AAEA,IAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,kJAAkJ;IACpJ,QAAQ,EAAE,cAAc;IACxB,WAAW,EAAE,QAAQ;IACrB,IAAI,EAAE,QAAQ;IACd,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE;QACX;YACE,KAAK,EAAE,8BAA8B;YACrC,WAAW,EAAE,yDAAyD;YACtE,IAAI,EAAE,sBAAsB;SAC7B;KACF;IACD,iBAAiB,EAAE,CAAC,4BAA4B,CAAC;IACjD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,8BAA8B;YACxC,GAAG,EAAE,4CAA4C;SAClD;QACD;YACE,IAAI,EAAE,wBAAwB;YAC9B,QAAQ,EAAE,mCAAmC;YAC7C,GAAG,EAAE,iDAAiD;SACvD;KACF;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Session, ShopifyRestResources } from '@shopify/shopify-api';
|
|
2
|
-
import { AdminApiContext } from '../../../
|
|
2
|
+
import { AdminApiContext, StorefrontContext } from '../../../clients';
|
|
3
3
|
export type AuthenticateAppProxy = (request: Request) => Promise<AppProxyContext | AppProxyContextWithSession>;
|
|
4
4
|
interface Options {
|
|
5
5
|
layout?: boolean;
|
|
@@ -10,7 +10,8 @@ interface Context {
|
|
|
10
10
|
* A utility for creating a Liquid Response.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* <caption>
|
|
13
|
+
* <caption>Rendering liquid content.</caption>
|
|
14
|
+
* <description>Use the `liquid` helper to render a `Response` with Liquid content.</description>
|
|
14
15
|
* ```ts
|
|
15
16
|
* // app/routes/**\/.ts
|
|
16
17
|
* import {authenticate} from "~/shopify.server"
|
|
@@ -34,9 +35,14 @@ export interface AppProxyContext extends Context {
|
|
|
34
35
|
session: undefined;
|
|
35
36
|
/**
|
|
36
37
|
* No session is available for the shop that made this request.
|
|
37
|
-
* Therefore no methods for interacting with the
|
|
38
|
+
* Therefore no methods for interacting with the GraphQL / REST Admin APIs are available.
|
|
38
39
|
*/
|
|
39
40
|
admin: undefined;
|
|
41
|
+
/**
|
|
42
|
+
* No session is available for the shop that made this request.
|
|
43
|
+
* Therefore no method for interacting with the Storefront API is available.
|
|
44
|
+
*/
|
|
45
|
+
storefront: undefined;
|
|
40
46
|
}
|
|
41
47
|
export interface AppProxyContextWithSession<Resources extends ShopifyRestResources = ShopifyRestResources> extends Context {
|
|
42
48
|
/**
|
|
@@ -44,27 +50,77 @@ export interface AppProxyContextWithSession<Resources extends ShopifyRestResourc
|
|
|
44
50
|
*
|
|
45
51
|
* This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice.
|
|
46
52
|
*
|
|
47
|
-
* Use this to get shop or user
|
|
53
|
+
* Use this to get shop or user-specific data.
|
|
48
54
|
*
|
|
49
55
|
* @example
|
|
50
|
-
* <caption>
|
|
56
|
+
* <caption>Using the session object.</caption>
|
|
57
|
+
* <description>Get your app's data using an offline session for the shop that made the request.</description>
|
|
51
58
|
* ```ts
|
|
52
59
|
* // app/routes/**\/.ts
|
|
53
60
|
* import { json } from "@remix-run/node";
|
|
54
61
|
* import { authenticate } from "../shopify.server";
|
|
55
|
-
* import {
|
|
62
|
+
* import { getMyAppModelData } from "~/db/model.server";
|
|
56
63
|
*
|
|
57
64
|
* export const loader = async ({ request }) => {
|
|
58
65
|
* const { session } = await authenticate.public.appProxy(request);
|
|
59
|
-
* return json(await
|
|
66
|
+
* return json(await getMyAppModelData({shop: session.shop));
|
|
60
67
|
* };
|
|
61
68
|
* ```
|
|
62
69
|
*/
|
|
63
70
|
session: Session;
|
|
64
71
|
/**
|
|
65
|
-
* Methods for interacting with the
|
|
72
|
+
* Methods for interacting with the GraphQL / REST Admin APIs for the store that made the request.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* <caption>Interacting with the Admin API.</caption>
|
|
76
|
+
* <description>Use the `admin` object to interact with the REST or GraphQL APIs.</description>
|
|
77
|
+
* ```ts
|
|
78
|
+
* // app/routes/**\/.ts
|
|
79
|
+
* import { json } from "@remix-run/node";
|
|
80
|
+
* import { authenticate } from "../shopify.server";
|
|
81
|
+
*
|
|
82
|
+
* export async function action({ request }: ActionArgs) {
|
|
83
|
+
* const { admin } = await authenticate.public.appProxy(request);
|
|
84
|
+
*
|
|
85
|
+
* const response = await admin.graphql(
|
|
86
|
+
* `#graphql
|
|
87
|
+
* mutation populateProduct($input: ProductInput!) {
|
|
88
|
+
* productCreate(input: $input) {
|
|
89
|
+
* product {
|
|
90
|
+
* id
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* }`,
|
|
94
|
+
* { variables: { input: { title: "Product Name" } } }
|
|
95
|
+
* );
|
|
96
|
+
*
|
|
97
|
+
* const productData = await response.json();
|
|
98
|
+
* return json({ data: productData.data });
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
66
101
|
*/
|
|
67
102
|
admin: AdminApiContext<Resources>;
|
|
103
|
+
/**
|
|
104
|
+
* Method for interacting with the Shopify Storefront Graphql API for the store that made the request.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* <caption>Interacting with the Storefront API.</caption>
|
|
108
|
+
* <description>Use the `storefront` object to interact with the GraphQL API.</description>
|
|
109
|
+
* ```ts
|
|
110
|
+
* // app/routes/**\/.ts
|
|
111
|
+
* import { json } from "@remix-run/node";
|
|
112
|
+
* import { authenticate } from "../shopify.server";
|
|
113
|
+
*
|
|
114
|
+
* export async function action({ request }: ActionArgs) {
|
|
115
|
+
* const { admin } = await authenticate.public.appProxy(request);
|
|
116
|
+
*
|
|
117
|
+
* const response = await storefront.graphql(`{blogs(first: 10) { edges { node { id } } } }`);
|
|
118
|
+
*
|
|
119
|
+
* return json(await response.json());
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
storefront: StorefrontContext;
|
|
68
124
|
}
|
|
69
125
|
export {};
|
|
70
126
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAC,eAAe,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/appProxy/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAC,eAAe,EAAE,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAEpE,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,eAAe,GAAG,0BAA0B,CAAC,CAAC;AAE3D,UAAU,OAAO;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG,CACnC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,KAC/C,QAAQ,CAAC;AAEd,UAAU,OAAO;IACf;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,EAAE,sBAAsB,CAAC;CAChC;AAED,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C;;;;OAIG;IACH,OAAO,EAAE,SAAS,CAAC;IAEnB;;;OAGG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;;OAGG;IACH,UAAU,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,0BAA0B,CACzC,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,CAC7D,SAAQ,OAAO;IACf;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAElC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,EAAE,iBAAiB,CAAC;CAC/B"}
|
package/build/ts/server/authenticate/public/checkout/authenticate.public.checkout.doc.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.public.checkout.doc.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/checkout/authenticate.public.checkout.doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,6BAkBX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var data = {
|
|
4
|
+
name: 'Checkout',
|
|
5
|
+
description: 'The `authenticate.public.checkout` function ensures that checkout extension requests are coming from Shopify, and returns helpers to respond with the correct headers.',
|
|
6
|
+
category: 'Authenticate',
|
|
7
|
+
subCategory: 'Public',
|
|
8
|
+
type: 'object',
|
|
9
|
+
isVisualComponent: false,
|
|
10
|
+
definitions: [
|
|
11
|
+
{
|
|
12
|
+
title: 'authenticate.public.checkout',
|
|
13
|
+
description: 'Authenticates requests coming from Shopify checkout extensions.',
|
|
14
|
+
type: 'AuthenticateCheckout',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
jsDocTypeExamples: ['CheckoutContext'],
|
|
18
|
+
related: [],
|
|
19
|
+
};
|
|
20
|
+
exports.default = data;
|
|
21
|
+
//# sourceMappingURL=authenticate.public.checkout.doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.public.checkout.doc.js","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/checkout/authenticate.public.checkout.doc.ts"],"names":[],"mappings":";;AAEA,IAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,UAAU;IAChB,WAAW,EACT,wKAAwK;IAC1K,QAAQ,EAAE,cAAc;IACxB,WAAW,EAAE,QAAQ;IACrB,IAAI,EAAE,QAAQ;IACd,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE;QACX;YACE,KAAK,EAAE,8BAA8B;YACrC,WAAW,EACT,iEAAiE;YACnE,IAAI,EAAE,sBAAsB;SAC7B;KACF;IACD,iBAAiB,EAAE,CAAC,iBAAiB,CAAC;IACtC,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -11,43 +11,45 @@ export interface CheckoutContext {
|
|
|
11
11
|
/**
|
|
12
12
|
* The decoded and validated session token for the request
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* Refer to the OAuth docs for the [session token payload](https://shopify.dev/docs/apps/auth/oauth/session-tokens#payload).
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
-
* <caption>
|
|
17
|
+
* <caption>Using the decoded session token.</caption>
|
|
18
|
+
* <description>Get store-specific data using the `sessionToken` object.</description>
|
|
18
19
|
* ```ts
|
|
19
|
-
* // app/routes/public/
|
|
20
|
+
* // app/routes/public/my-route.ts
|
|
20
21
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
21
22
|
* import { authenticate } from "../shopify.server";
|
|
22
|
-
* import {
|
|
23
|
+
* import { getMyAppData } from "~/db/model.server";
|
|
23
24
|
*
|
|
24
25
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
25
|
-
* const { sessionToken } = await authenticate.public(
|
|
26
|
+
* const { sessionToken } = await authenticate.public.checkout(
|
|
26
27
|
* request
|
|
27
28
|
* );
|
|
28
|
-
* return json(await
|
|
29
|
+
* return json(await getMyAppData({shop: sessionToken.dest}));
|
|
29
30
|
* };
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
33
|
sessionToken: JwtPayload;
|
|
33
34
|
/**
|
|
34
|
-
* A function that ensures the CORS headers are set correctly for the response
|
|
35
|
+
* A function that ensures the CORS headers are set correctly for the response.
|
|
35
36
|
*
|
|
36
37
|
* @example
|
|
37
|
-
* <caption>Setting CORS headers for a public request
|
|
38
|
+
* <caption>Setting CORS headers for a public request.</caption>
|
|
39
|
+
* <description>Use the `cors` helper to ensure your app can respond to checkout extension requests.</description>
|
|
38
40
|
* ```ts
|
|
39
|
-
* // app/routes/public/
|
|
41
|
+
* // app/routes/public/my-route.ts
|
|
40
42
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
41
43
|
* import { authenticate } from "../shopify.server";
|
|
42
|
-
* import {
|
|
44
|
+
* import { getMyAppData } from "~/db/model.server";
|
|
43
45
|
*
|
|
44
46
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
45
|
-
* const { sessionToken, cors } = await authenticate.public(
|
|
47
|
+
* const { sessionToken, cors } = await authenticate.public.checkout(
|
|
46
48
|
* request,
|
|
47
49
|
* { corsHeaders: ["X-My-Custom-Header"] }
|
|
48
50
|
* );
|
|
49
|
-
* const
|
|
50
|
-
* return cors(json(
|
|
51
|
+
* const data = await getMyAppData({shop: sessionToken.dest});
|
|
52
|
+
* return cors(json(data));
|
|
51
53
|
* };
|
|
52
54
|
* ```
|
|
53
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/checkout/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,2BAA2B,KAClC,OAAO,CAAC,eAAe,CAAC,CAAC;AAE9B,MAAM,WAAW,2BAA2B;IAC1C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/public/checkout/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,2BAA2B,KAClC,OAAO,CAAC,eAAe,CAAC,CAAC;AAE9B,MAAM,WAAW,2BAA2B;IAC1C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,EAAE,UAAU,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,IAAI,EAAE,kBAAkB,CAAC;CAC1B"}
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import type { AuthenticateCheckout } from './checkout/types';
|
|
2
2
|
import type { AuthenticateAppProxy } from './appProxy/types';
|
|
3
|
-
|
|
4
|
-
* Methods for authenticating Requests from Shopify's public surfaces
|
|
5
|
-
*
|
|
6
|
-
* To maintain backwards compatability this is a function and an object.
|
|
7
|
-
*
|
|
8
|
-
* Do not use `authenticate.public()`. Use `authenticate.public.checkout()` instead.
|
|
9
|
-
* `authenticate.public()` will be removed in v2.
|
|
10
|
-
*
|
|
11
|
-
* Methods are:
|
|
12
|
-
*
|
|
13
|
-
* - `authenticate.public.checkout()` for authenticating requests from checkout extensions
|
|
14
|
-
* - `authenticate.public.appProxy()` for authenticating requests from app proxies
|
|
15
|
-
*/
|
|
16
|
-
export type AuthenticatePublic = AuthenticateCheckout & {
|
|
3
|
+
interface AuthenticatePublicObject {
|
|
17
4
|
/**
|
|
18
5
|
* Authenticate a request from a checkout extension
|
|
19
6
|
*
|
|
20
7
|
* @example
|
|
21
8
|
* <caption>Authenticating a checkout extension request</caption>
|
|
22
9
|
* ```ts
|
|
23
|
-
* // app/routes/public/widgets.ts
|
|
10
|
+
* // /app/routes/public/widgets.ts
|
|
24
11
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
25
12
|
* import { authenticate } from "../shopify.server";
|
|
26
13
|
*
|
|
@@ -39,7 +26,7 @@ export type AuthenticatePublic = AuthenticateCheckout & {
|
|
|
39
26
|
* @example
|
|
40
27
|
* <caption>Authenticating an app proxy request</caption>
|
|
41
28
|
* ```ts
|
|
42
|
-
* // app/routes/public/widgets.ts
|
|
29
|
+
* // /app/routes/public/widgets.ts
|
|
43
30
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
44
31
|
* import { authenticate } from "../shopify.server";
|
|
45
32
|
*
|
|
@@ -57,5 +44,20 @@ export type AuthenticatePublic = AuthenticateCheckout & {
|
|
|
57
44
|
* ```
|
|
58
45
|
*/
|
|
59
46
|
appProxy: AuthenticateAppProxy;
|
|
60
|
-
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Methods for authenticating Requests from Shopify's public surfaces
|
|
50
|
+
*
|
|
51
|
+
* To maintain backwards compatability this is a function and an object.
|
|
52
|
+
*
|
|
53
|
+
* Do not use `authenticate.public()`. Use `authenticate.public.checkout()` instead.
|
|
54
|
+
* `authenticate.public()` will be removed in v2.
|
|
55
|
+
*
|
|
56
|
+
* Methods are:
|
|
57
|
+
*
|
|
58
|
+
* - `authenticate.public.checkout()` for authenticating requests from checkout extensions
|
|
59
|
+
* - `authenticate.public.appProxy()` for authenticating requests from app proxies
|
|
60
|
+
*/
|
|
61
|
+
export type AuthenticatePublic = AuthenticateCheckout & AuthenticatePublicObject;
|
|
62
|
+
export {};
|
|
61
63
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/public/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAO3D
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/public/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAO3D,UAAU,wBAAwB;IAChC;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,EAAE,oBAAoB,CAAC;IAE/B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GACnD,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.webhooks.doc.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/authenticate.webhooks.doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,6BAeX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|