@platform-x-shp/shopify-adapter 0.3.0 → 0.5.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/dist/src/customers.d.ts +46 -0
- package/dist/src/customers.d.ts.map +1 -1
- package/dist/src/customers.js +195 -0
- package/dist/src/customers.js.map +1 -1
- package/dist/src/delivery-sso.d.ts +44 -0
- package/dist/src/delivery-sso.d.ts.map +1 -0
- package/dist/src/delivery-sso.js +404 -0
- package/dist/src/delivery-sso.js.map +1 -0
- package/dist/src/index.d.ts +6 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +24 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/orders.d.ts +135 -0
- package/dist/src/orders.d.ts.map +1 -1
- package/dist/src/orders.js +303 -0
- package/dist/src/orders.js.map +1 -1
- package/package.json +1 -1
package/dist/src/customers.d.ts
CHANGED
|
@@ -9,6 +9,38 @@ export interface ShopifyCustomer {
|
|
|
9
9
|
updatedAt?: string;
|
|
10
10
|
defaultAddressId?: string;
|
|
11
11
|
}
|
|
12
|
+
export interface CustomerUpdateInput {
|
|
13
|
+
firstName?: string;
|
|
14
|
+
lastName?: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
phone?: string;
|
|
17
|
+
acceptsMarketing?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ShopifyAddress {
|
|
20
|
+
shopifyId: string;
|
|
21
|
+
firstName?: string;
|
|
22
|
+
lastName?: string;
|
|
23
|
+
address1?: string;
|
|
24
|
+
address2?: string;
|
|
25
|
+
city?: string;
|
|
26
|
+
province?: string;
|
|
27
|
+
country?: string;
|
|
28
|
+
zip?: string;
|
|
29
|
+
phone?: string;
|
|
30
|
+
isDefault: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface AddressInput {
|
|
33
|
+
firstName?: string;
|
|
34
|
+
lastName?: string;
|
|
35
|
+
address1?: string;
|
|
36
|
+
address2?: string;
|
|
37
|
+
city?: string;
|
|
38
|
+
province?: string;
|
|
39
|
+
country?: string;
|
|
40
|
+
zip?: string;
|
|
41
|
+
phone?: string;
|
|
42
|
+
setAsDefault?: boolean;
|
|
43
|
+
}
|
|
12
44
|
/** Fetch a customer by Shopify ID; `null` if missing. */
|
|
13
45
|
export declare function getCustomerById(siteName: string, customerId: string): Promise<ShopifyCustomer | null>;
|
|
14
46
|
/**
|
|
@@ -16,4 +48,18 @@ export declare function getCustomerById(siteName: string, customerId: string): P
|
|
|
16
48
|
* auth principal's email claim rather than a Shopify customer GID.
|
|
17
49
|
*/
|
|
18
50
|
export declare function getCustomerByEmail(siteName: string, email: string): Promise<ShopifyCustomer | null>;
|
|
51
|
+
/** Update a customer's profile fields. `acceptsMarketing` goes through a separate consent mutation, same as shp-customer-service. */
|
|
52
|
+
export declare function updateCustomer(siteName: string, customerId: string, input: CustomerUpdateInput): Promise<ShopifyCustomer>;
|
|
53
|
+
/** List a customer's addresses, each flagged with whether it's the default — `null` if the customer doesn't exist. */
|
|
54
|
+
export declare function listCustomerAddresses(siteName: string, customerId: string): Promise<ShopifyAddress[] | null>;
|
|
55
|
+
/** Fetch a single address by ID (numeric or full GID) — `null` if the customer or address doesn't exist. */
|
|
56
|
+
export declare function getCustomerAddress(siteName: string, customerId: string, addressId: string): Promise<ShopifyAddress | null>;
|
|
57
|
+
/** Add a new address to a customer, optionally setting it as their default. */
|
|
58
|
+
export declare function createCustomerAddress(siteName: string, customerId: string, input: AddressInput): Promise<ShopifyAddress>;
|
|
59
|
+
/** Update an existing address's fields, optionally setting it as the default. `null` if the address doesn't exist. */
|
|
60
|
+
export declare function updateCustomerAddress(siteName: string, customerId: string, addressId: string, input: AddressInput): Promise<ShopifyAddress | null>;
|
|
61
|
+
/** Remove an address from a customer, returning its resolved ID — `null` if it doesn't exist. */
|
|
62
|
+
export declare function deleteCustomerAddress(siteName: string, customerId: string, addressId: string): Promise<string | null>;
|
|
63
|
+
/** Set an existing address as the customer's default — `null` if it doesn't exist. */
|
|
64
|
+
export declare function setDefaultCustomerAddress(siteName: string, customerId: string, addressId: string): Promise<ShopifyCustomer | null>;
|
|
19
65
|
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/customers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/customers.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf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ClB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,cAAc,CAAC,CAwBzB;AAED,sHAAsH;AACtH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA2BhC;AAED,iGAAiG;AACjG,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxB;AAED,sFAAsF;AACtF,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA2BjC"}
|
package/dist/src/customers.js
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCustomerById = getCustomerById;
|
|
4
4
|
exports.getCustomerByEmail = getCustomerByEmail;
|
|
5
|
+
exports.updateCustomer = updateCustomer;
|
|
6
|
+
exports.listCustomerAddresses = listCustomerAddresses;
|
|
7
|
+
exports.getCustomerAddress = getCustomerAddress;
|
|
8
|
+
exports.createCustomerAddress = createCustomerAddress;
|
|
9
|
+
exports.updateCustomerAddress = updateCustomerAddress;
|
|
10
|
+
exports.deleteCustomerAddress = deleteCustomerAddress;
|
|
11
|
+
exports.setDefaultCustomerAddress = setDefaultCustomerAddress;
|
|
5
12
|
const client_1 = require("./client");
|
|
13
|
+
const errors_1 = require("./errors");
|
|
6
14
|
const CUSTOMER_FIELDS = `
|
|
7
15
|
id
|
|
8
16
|
firstName
|
|
@@ -20,6 +28,32 @@ function toAcceptsMarketing(node) {
|
|
|
20
28
|
function normalizeCustomerId(customerId) {
|
|
21
29
|
return customerId.startsWith('gid://shopify/Customer/') ? customerId : `gid://shopify/Customer/${customerId}`;
|
|
22
30
|
}
|
|
31
|
+
/** The trailing numeric segment of a GID (strips any `?`-suffixed query Shopify sometimes appends to address GIDs). */
|
|
32
|
+
function extractNumericId(gid) {
|
|
33
|
+
const last = gid.split('/').pop() ?? gid;
|
|
34
|
+
return last.split('?')[0] ?? last;
|
|
35
|
+
}
|
|
36
|
+
function ensureNoUserErrors(errors, message) {
|
|
37
|
+
if (errors && errors.length > 0) {
|
|
38
|
+
throw new errors_1.ShopifyUserErrorsError(message, errors);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function mapAddress(node, isDefault) {
|
|
42
|
+
return {
|
|
43
|
+
shopifyId: node.id,
|
|
44
|
+
firstName: node.firstName ?? undefined,
|
|
45
|
+
lastName: node.lastName ?? undefined,
|
|
46
|
+
address1: node.address1 ?? undefined,
|
|
47
|
+
address2: node.address2 ?? undefined,
|
|
48
|
+
city: node.city ?? undefined,
|
|
49
|
+
province: node.province ?? undefined,
|
|
50
|
+
country: node.country ?? undefined,
|
|
51
|
+
zip: node.zip ?? undefined,
|
|
52
|
+
phone: node.phone ?? undefined,
|
|
53
|
+
isDefault,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const ADDRESS_FIELDS = `id firstName lastName address1 address2 city province country zip phone`;
|
|
23
57
|
function mapCustomer(node) {
|
|
24
58
|
return {
|
|
25
59
|
shopifyId: node.id,
|
|
@@ -59,4 +93,165 @@ async function getCustomerByEmail(siteName, email) {
|
|
|
59
93
|
const customer = data.customers.nodes[0];
|
|
60
94
|
return customer ? mapCustomer(customer) : null;
|
|
61
95
|
}
|
|
96
|
+
async function updateCustomerEmailMarketingConsent(siteName, customerId, acceptsMarketing) {
|
|
97
|
+
const mutation = `
|
|
98
|
+
mutation UpdateCustomerEmailMarketingConsent($input: CustomerEmailMarketingConsentUpdateInput!) {
|
|
99
|
+
customerEmailMarketingConsentUpdate(input: $input) {
|
|
100
|
+
userErrors { field message }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
const data = await (0, client_1.adminGraphql)(siteName, mutation, {
|
|
105
|
+
input: {
|
|
106
|
+
customerId: normalizeCustomerId(customerId),
|
|
107
|
+
emailMarketingConsent: {
|
|
108
|
+
marketingState: acceptsMarketing ? 'SUBSCRIBED' : 'UNSUBSCRIBED',
|
|
109
|
+
marketingOptInLevel: 'SINGLE_OPT_IN',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
ensureNoUserErrors(data.customerEmailMarketingConsentUpdate.userErrors, 'Failed to update marketing consent');
|
|
114
|
+
}
|
|
115
|
+
/** Update a customer's profile fields. `acceptsMarketing` goes through a separate consent mutation, same as shp-customer-service. */
|
|
116
|
+
async function updateCustomer(siteName, customerId, input) {
|
|
117
|
+
const { acceptsMarketing, ...rest } = input;
|
|
118
|
+
const mutation = `
|
|
119
|
+
mutation UpdateCustomer($input: CustomerInput!) {
|
|
120
|
+
customerUpdate(input: $input) {
|
|
121
|
+
customer { id }
|
|
122
|
+
userErrors { field message }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
const data = await (0, client_1.adminGraphql)(siteName, mutation, { input: { id: normalizeCustomerId(customerId), ...rest } });
|
|
127
|
+
ensureNoUserErrors(data.customerUpdate.userErrors, 'Failed to update customer');
|
|
128
|
+
if (typeof acceptsMarketing === 'boolean') {
|
|
129
|
+
await updateCustomerEmailMarketingConsent(siteName, customerId, acceptsMarketing);
|
|
130
|
+
}
|
|
131
|
+
const updated = await getCustomerById(siteName, customerId);
|
|
132
|
+
if (!updated) {
|
|
133
|
+
throw new errors_1.ShopifyNotFoundError('Customer not found', { customerId });
|
|
134
|
+
}
|
|
135
|
+
return updated;
|
|
136
|
+
}
|
|
137
|
+
/** List a customer's addresses, each flagged with whether it's the default — `null` if the customer doesn't exist. */
|
|
138
|
+
async function listCustomerAddresses(siteName, customerId) {
|
|
139
|
+
const query = `
|
|
140
|
+
query CustomerAddresses($id: ID!) {
|
|
141
|
+
customer(id: $id) {
|
|
142
|
+
defaultAddress { id }
|
|
143
|
+
addresses { ${ADDRESS_FIELDS} }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
const data = await (0, client_1.adminGraphql)(siteName, query, { id: normalizeCustomerId(customerId) });
|
|
148
|
+
if (!data.customer) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
const defaultNumericId = data.customer.defaultAddress ? extractNumericId(data.customer.defaultAddress.id) : null;
|
|
152
|
+
return (data.customer.addresses ?? []).map((node) => mapAddress(node, defaultNumericId !== null && extractNumericId(node.id) === defaultNumericId));
|
|
153
|
+
}
|
|
154
|
+
/** Fetch a single address by ID (numeric or full GID) — `null` if the customer or address doesn't exist. */
|
|
155
|
+
async function getCustomerAddress(siteName, customerId, addressId) {
|
|
156
|
+
const addresses = await listCustomerAddresses(siteName, customerId);
|
|
157
|
+
if (!addresses) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const target = extractNumericId(addressId);
|
|
161
|
+
return addresses.find((address) => extractNumericId(address.shopifyId) === target) ?? null;
|
|
162
|
+
}
|
|
163
|
+
/** Add a new address to a customer, optionally setting it as their default. */
|
|
164
|
+
async function createCustomerAddress(siteName, customerId, input) {
|
|
165
|
+
const { setAsDefault, ...address } = input;
|
|
166
|
+
const mutation = `
|
|
167
|
+
mutation CreateCustomerAddress($customerId: ID!, $address: MailingAddressInput!) {
|
|
168
|
+
customerAddressCreate(customerId: $customerId, address: $address) {
|
|
169
|
+
address { ${ADDRESS_FIELDS} }
|
|
170
|
+
userErrors { field message }
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
const data = await (0, client_1.adminGraphql)(siteName, mutation, { customerId: normalizeCustomerId(customerId), address });
|
|
175
|
+
ensureNoUserErrors(data.customerAddressCreate.userErrors, 'Failed to create customer address');
|
|
176
|
+
if (!data.customerAddressCreate.address) {
|
|
177
|
+
throw new errors_1.ShopifyUserErrorsError('Failed to create customer address', data.customerAddressCreate.userErrors);
|
|
178
|
+
}
|
|
179
|
+
if (setAsDefault) {
|
|
180
|
+
await setDefaultCustomerAddress(siteName, customerId, data.customerAddressCreate.address.id);
|
|
181
|
+
const updated = await getCustomerAddress(siteName, customerId, data.customerAddressCreate.address.id);
|
|
182
|
+
if (updated)
|
|
183
|
+
return updated;
|
|
184
|
+
}
|
|
185
|
+
return mapAddress(data.customerAddressCreate.address, false);
|
|
186
|
+
}
|
|
187
|
+
/** Update an existing address's fields, optionally setting it as the default. `null` if the address doesn't exist. */
|
|
188
|
+
async function updateCustomerAddress(siteName, customerId, addressId, input) {
|
|
189
|
+
const resolved = await getCustomerAddress(siteName, customerId, addressId);
|
|
190
|
+
if (!resolved) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
const { setAsDefault, ...address } = input;
|
|
194
|
+
const mutation = `
|
|
195
|
+
mutation UpdateCustomerAddress($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) {
|
|
196
|
+
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) {
|
|
197
|
+
address { ${ADDRESS_FIELDS} }
|
|
198
|
+
userErrors { field message }
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
`;
|
|
202
|
+
const data = await (0, client_1.adminGraphql)(siteName, mutation, {
|
|
203
|
+
customerId: normalizeCustomerId(customerId),
|
|
204
|
+
addressId: resolved.shopifyId,
|
|
205
|
+
address,
|
|
206
|
+
});
|
|
207
|
+
ensureNoUserErrors(data.customerAddressUpdate.userErrors, 'Failed to update customer address');
|
|
208
|
+
if (setAsDefault) {
|
|
209
|
+
await setDefaultCustomerAddress(siteName, customerId, resolved.shopifyId);
|
|
210
|
+
}
|
|
211
|
+
return getCustomerAddress(siteName, customerId, resolved.shopifyId);
|
|
212
|
+
}
|
|
213
|
+
/** Remove an address from a customer, returning its resolved ID — `null` if it doesn't exist. */
|
|
214
|
+
async function deleteCustomerAddress(siteName, customerId, addressId) {
|
|
215
|
+
const resolved = await getCustomerAddress(siteName, customerId, addressId);
|
|
216
|
+
if (!resolved) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
const mutation = `
|
|
220
|
+
mutation DeleteCustomerAddress($customerId: ID!, $addressId: ID!) {
|
|
221
|
+
customerAddressDelete(customerId: $customerId, addressId: $addressId) {
|
|
222
|
+
userErrors { field message }
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
`;
|
|
226
|
+
const data = await (0, client_1.adminGraphql)(siteName, mutation, { customerId: normalizeCustomerId(customerId), addressId: resolved.shopifyId });
|
|
227
|
+
ensureNoUserErrors(data.customerAddressDelete.userErrors, 'Failed to delete customer address');
|
|
228
|
+
return resolved.shopifyId;
|
|
229
|
+
}
|
|
230
|
+
/** Set an existing address as the customer's default — `null` if it doesn't exist. */
|
|
231
|
+
async function setDefaultCustomerAddress(siteName, customerId, addressId) {
|
|
232
|
+
const resolved = await getCustomerAddress(siteName, customerId, addressId);
|
|
233
|
+
if (!resolved) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const mutation = `
|
|
237
|
+
mutation SetDefaultCustomerAddress($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) {
|
|
238
|
+
customerAddressUpdate(
|
|
239
|
+
customerId: $customerId
|
|
240
|
+
addressId: $addressId
|
|
241
|
+
address: $address
|
|
242
|
+
setAsDefault: $setAsDefault
|
|
243
|
+
) {
|
|
244
|
+
userErrors { field message }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
`;
|
|
248
|
+
const data = await (0, client_1.adminGraphql)(siteName, mutation, {
|
|
249
|
+
customerId: normalizeCustomerId(customerId),
|
|
250
|
+
addressId: resolved.shopifyId,
|
|
251
|
+
address: {},
|
|
252
|
+
setAsDefault: true,
|
|
253
|
+
});
|
|
254
|
+
ensureNoUserErrors(data.customerAddressUpdate.userErrors, 'Failed to set default customer address');
|
|
255
|
+
return getCustomerById(siteName, customerId);
|
|
256
|
+
}
|
|
62
257
|
//# sourceMappingURL=customers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/customers.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/customers.ts"],"names":[],"mappings":";;AAmHA,0CASC;AAMD,gDAYC;AA6BD,wCA4BC;AAGD,sDAmBC;AAGD,gDAWC;AAGD,sDA4BC;AAGD,sDAgCC;AAGD,sDAqBC;AAGD,8DA+BC;AAvWD,qCAAwC;AACxC,qCAA+F;AAiD/F,MAAM,eAAe,GAAG;;;;;;;;;;CAUvB,CAAC;AAEF,SAAS,kBAAkB,CAAC,IAA6D;IACvF,OAAO,IAAI,CAAC,qBAAqB,EAAE,cAAc,KAAK,YAAY,CAAC;AACrE,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAkB;IAC7C,OAAO,UAAU,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,0BAA0B,UAAU,EAAE,CAAC;AAChH,CAAC;AAED,uHAAuH;AACvH,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACpC,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAsC,EAAE,OAAe;IACjF,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,+BAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAS,EAAE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IACH,kBAAkB,CAAC,IAAI,CAAC,qBAAqB,CAAC,UAAU,EAAE,wCAAwC,CAAC,CAAC;IACpG,OAAO,eAAe,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
export declare const SESSION_COOKIE_NAME = "shp_delivery_sid";
|
|
3
|
+
export interface MintedSession {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
expiresIn: number;
|
|
6
|
+
customer: {
|
|
7
|
+
id: string;
|
|
8
|
+
email: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface DeliverySsoConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Public base URL this module's Shopify-callback route is reachable at —
|
|
14
|
+
* e.g. `https://dev.hep-ecommerce-service.hcl-x.com/hep-ecommerce-service/auth/delivery`.
|
|
15
|
+
* `/shopify/callback` is appended to build the `redirect_uri` sent to
|
|
16
|
+
* Shopify, which must exactly match what's registered in the Customer
|
|
17
|
+
* Account API app's allowed redirect URIs.
|
|
18
|
+
*/
|
|
19
|
+
callbackBaseUrl: string;
|
|
20
|
+
/**
|
|
21
|
+
* Path the router below is mounted at (e.g.
|
|
22
|
+
* `/hep-ecommerce-service/auth/delivery`) — used only to scope the session
|
|
23
|
+
* cookie, so it isn't sent on unrelated routes.
|
|
24
|
+
*/
|
|
25
|
+
sessionCookiePath: string;
|
|
26
|
+
/** Allow-list `beginDeliverySso`'s `returnUrl` and the session/logout endpoints' CORS are locked to. */
|
|
27
|
+
allowedReturnOrigins: string[];
|
|
28
|
+
}
|
|
29
|
+
/** Step 1: validate returnUrl, stash PKCE/nonce under a fresh `state`, and build Shopify's own authorize URL. */
|
|
30
|
+
export declare function beginDeliverySso(siteName: string, returnUrl: string, config: DeliverySsoConfig): Promise<{
|
|
31
|
+
authorizeUrl: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Express router exposing the 3 HTTP legs of delivery SSO: Shopify's own
|
|
35
|
+
* callback (GET `/shopify/callback`), and the SPA's own credentialed calls
|
|
36
|
+
* to mint (POST `/session`) and end (POST `/logout`) a bearer. Mount this at
|
|
37
|
+
* `config.callbackBaseUrl`'s path (e.g.
|
|
38
|
+
* `/hep-ecommerce-service/auth/delivery`) so the routes resolve to exactly
|
|
39
|
+
* the URLs `config` describes. `beginDeliverySso` is a plain function, not a
|
|
40
|
+
* route here — call it from your own GraphQL/REST mutation, same as every
|
|
41
|
+
* other write in this package.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createDeliverySsoRouter(config: DeliverySsoConfig): Router;
|
|
44
|
+
//# sourceMappingURL=delivery-sso.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-sso.d.ts","sourceRoot":"","sources":["../../src/delivery-sso.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAqE,MAAM,SAAS,CAAC;AA8CpG,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AA0BtD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wGAAwG;IACxG,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAqGD,iHAAiH;AACjH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBnC;AAwLD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAqEzE"}
|