@platform-x-shp/shopify-adapter 0.6.0 → 0.6.2
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.
|
@@ -11,7 +11,7 @@ export interface MintedSession {
|
|
|
11
11
|
export interface DeliverySsoConfig {
|
|
12
12
|
/**
|
|
13
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
|
|
14
|
+
* e.g. `https://dev.hep-ecommerce-service.hcl-x.com/hep-ecommerce-service/delivery/auth`.
|
|
15
15
|
* `/shopify/callback` is appended to build the `redirect_uri` sent to
|
|
16
16
|
* Shopify, which must exactly match what's registered in the Customer
|
|
17
17
|
* Account API app's allowed redirect URIs.
|
|
@@ -19,7 +19,7 @@ export interface DeliverySsoConfig {
|
|
|
19
19
|
callbackBaseUrl: string;
|
|
20
20
|
/**
|
|
21
21
|
* Path the router below is mounted at (e.g.
|
|
22
|
-
* `/hep-ecommerce-service/auth
|
|
22
|
+
* `/hep-ecommerce-service/delivery/auth`) — used only to scope the session
|
|
23
23
|
* cookie, so it isn't sent on unrelated routes.
|
|
24
24
|
*/
|
|
25
25
|
sessionCookiePath: string;
|
|
@@ -35,7 +35,7 @@ export declare function beginDeliverySso(siteName: string, returnUrl: string, co
|
|
|
35
35
|
* callback (GET `/shopify/callback`), and the SPA's own credentialed calls
|
|
36
36
|
* to mint (POST `/session`) and end (POST `/logout`) a bearer. Mount this at
|
|
37
37
|
* `config.callbackBaseUrl`'s path (e.g.
|
|
38
|
-
* `/hep-ecommerce-service/auth
|
|
38
|
+
* `/hep-ecommerce-service/delivery/auth`) so the routes resolve to exactly
|
|
39
39
|
* the URLs `config` describes. `beginDeliverySso` is a plain function, not a
|
|
40
40
|
* route here — call it from your own GraphQL/REST mutation, same as every
|
|
41
41
|
* other write in this package.
|
package/dist/src/delivery-sso.js
CHANGED
|
@@ -324,7 +324,7 @@ function sessionCors(config) {
|
|
|
324
324
|
* callback (GET `/shopify/callback`), and the SPA's own credentialed calls
|
|
325
325
|
* to mint (POST `/session`) and end (POST `/logout`) a bearer. Mount this at
|
|
326
326
|
* `config.callbackBaseUrl`'s path (e.g.
|
|
327
|
-
* `/hep-ecommerce-service/auth
|
|
327
|
+
* `/hep-ecommerce-service/delivery/auth`) so the routes resolve to exactly
|
|
328
328
|
* the URLs `config` describes. `beginDeliverySso` is a plain function, not a
|
|
329
329
|
* route here — call it from your own GraphQL/REST mutation, same as every
|
|
330
330
|
* other write in this package.
|
|
@@ -19,7 +19,7 @@ export interface KeycloakVerifyConfig {
|
|
|
19
19
|
* Restrict verification to tokens issued to this specific Keycloak client
|
|
20
20
|
* (checked against the token's `azp` claim — the "authorized party" that
|
|
21
21
|
* requested it). Set this to enforce that a request declaring
|
|
22
|
-
* `
|
|
22
|
+
* `platformtype: authoring` actually carries a token issued by the
|
|
23
23
|
* authoring client, not a delivery-flow (or any other) token replayed
|
|
24
24
|
* across flows. Omit for no such check (the pre-existing behavior).
|
|
25
25
|
*/
|
|
@@ -44,11 +44,11 @@ export declare function verifyKeycloakToken(token: string, config: KeycloakVerif
|
|
|
44
44
|
* `getTenantConfig`). `audience` is passed through as-is — it isn't part of
|
|
45
45
|
* `KeycloakConfig` since it's a per-caller restriction, not a per-tenant secret.
|
|
46
46
|
*
|
|
47
|
-
* `requestSource` (the request's `
|
|
47
|
+
* `requestSource` (the request's `platformtype` header value) — when it's
|
|
48
48
|
* recognizably `'authoring'` or `'delivery'` — sets `expectedClientId` to that
|
|
49
49
|
* flow's registered Keycloak client, so `verifyKeycloakToken` rejects a token
|
|
50
50
|
* that wasn't actually issued to that flow's client (e.g. a delivery-issued
|
|
51
|
-
* token replayed with `
|
|
51
|
+
* token replayed with `platformtype: authoring`). Omit it, or pass an
|
|
52
52
|
* unrecognized value, to skip that check — the pre-existing behavior.
|
|
53
53
|
*/
|
|
54
54
|
export declare function keycloakConfigForTenant(siteName: string, audience?: string, requestSource?: string): Promise<KeycloakVerifyConfig>;
|
|
@@ -12,7 +12,7 @@ const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
|
12
12
|
const tenant_errors_1 = require("./tenant-errors");
|
|
13
13
|
const tenant_config_1 = require("./tenant-config");
|
|
14
14
|
const logger_1 = require("./utils/logger");
|
|
15
|
-
/** Normalizes a `
|
|
15
|
+
/** Normalizes a `platformtype` header value; anything else is treated as unrecognized. */
|
|
16
16
|
function normalizeRequestSource(requestSource) {
|
|
17
17
|
const value = requestSource?.trim().toLowerCase();
|
|
18
18
|
return value === 'authoring' || value === 'delivery' ? value : undefined;
|
|
@@ -70,7 +70,7 @@ function verifyKeycloakToken(token, config) {
|
|
|
70
70
|
}
|
|
71
71
|
const payload = decoded;
|
|
72
72
|
if (config.expectedClientId && payload.azp !== config.expectedClientId) {
|
|
73
|
-
reject(new tenant_errors_1.TokenInvalidError('Token was not issued by the expected client for this
|
|
73
|
+
reject(new tenant_errors_1.TokenInvalidError('Token was not issued by the expected client for this platformtype'));
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
resolve(payload);
|
|
@@ -82,11 +82,11 @@ function verifyKeycloakToken(token, config) {
|
|
|
82
82
|
* `getTenantConfig`). `audience` is passed through as-is — it isn't part of
|
|
83
83
|
* `KeycloakConfig` since it's a per-caller restriction, not a per-tenant secret.
|
|
84
84
|
*
|
|
85
|
-
* `requestSource` (the request's `
|
|
85
|
+
* `requestSource` (the request's `platformtype` header value) — when it's
|
|
86
86
|
* recognizably `'authoring'` or `'delivery'` — sets `expectedClientId` to that
|
|
87
87
|
* flow's registered Keycloak client, so `verifyKeycloakToken` rejects a token
|
|
88
88
|
* that wasn't actually issued to that flow's client (e.g. a delivery-issued
|
|
89
|
-
* token replayed with `
|
|
89
|
+
* token replayed with `platformtype: authoring`). Omit it, or pass an
|
|
90
90
|
* unrecognized value, to skip that check — the pre-existing behavior.
|
|
91
91
|
*/
|
|
92
92
|
async function keycloakConfigForTenant(siteName, audience, requestSource) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keycloak-auth.js","sourceRoot":"","sources":["../../src/keycloak-auth.ts"],"names":[],"mappings":";;;;;AA4DA,sCAMC;AAOD,kDAmCC;AAcD,0DAaC;AASD,kDAeC;AA9JD,gEAA4E;AAC5E,wDAAuD;AAEvD,mDAA0F;AAC1F,mDAAkD;AAClD,2CAAwC;AAExC,
|
|
1
|
+
{"version":3,"file":"keycloak-auth.js","sourceRoot":"","sources":["../../src/keycloak-auth.ts"],"names":[],"mappings":";;;;;AA4DA,sCAMC;AAOD,kDAmCC;AAcD,0DAaC;AASD,kDAeC;AA9JD,gEAA4E;AAC5E,wDAAuD;AAEvD,mDAA0F;AAC1F,mDAAkD;AAClD,2CAAwC;AAExC,0FAA0F;AAC1F,SAAS,sBAAsB,CAAC,aAAsB;IACpD,MAAM,KAAK,GAAG,aAAa,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClD,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AA4BD,4EAA4E;AAC5E,4DAA4D;AAC5D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;AAElD,SAAS,aAAa,CAAC,OAAe;IACpC,IAAI,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAA,kBAAU,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,aAAsB;IAClD,MAAM,KAAK,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C,MAAuG;IAEvG,OAAO,CAAC,GAAY,EAAE,IAAc,EAAE,IAAkB,EAAQ,EAAE;QAChE,OAAO,CAAC,OAAO,EAAE;aACd,IAAI,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;YACzD,MAAM,cAAc,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACjF,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;YACjE,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxE,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC;QAC7B,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;aAClB,KAAK,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platform-x-shp/shopify-adapter",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Shopify commerce adapter — Admin API client, read-model mappers, tenant-config resolution, and Keycloak/PlatformX auth verification, consumed by hep-ecommerce-service. Self-contained: does not depend on shp-auth-client.",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|