@cronvello/shop-sdk 0.2.2 → 0.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/dist/index.js CHANGED
@@ -2089,7 +2089,7 @@ var apiRoutes_external_apps = {
2089
2089
  meta: {
2090
2090
  tags: ["external-apps"],
2091
2091
  summary: "Get external app registration status (B2B)",
2092
- description: "Returns registration status for an app identified by its string appId. Used by AMP to discover existing connections. Includes authMethod and, for OAuth apps, the oauth client_id we will present to that app plus a truncated SHA-256 fingerprint of the stored client secret, so the other side can prove a rotation actually landed here. Never the secret itself. Also reports the entitlement paths we have stored, because registration is an upsert: a caller that only wants to hand us new credentials must send these back unchanged, or it silently repoints where we fetch entitlements from."
2092
+ description: "Returns registration status for an app identified by its string appId. Used by AMP to discover existing connections. Includes authMethod and, for OAuth apps, the oauth client_id we will present to that app plus a truncated SHA-256 fingerprint of the stored client secret, so the other side can prove a rotation actually landed here. Never the secret itself. `credentialFingerprints` lists one such fingerprint per credential we hold for that app (api_key, previous_api_key during a rotation grace period, public_api_key, oauth_client_secret). It lets the caller locate the value in the app's runtime environment by equality instead of guessing a variable name - the name differs per app, the value does not. Also reports the entitlement paths we have stored, because registration is an upsert: a caller that only wants to hand us new credentials must send these back unchanged, or it silently repoints where we fetch entitlements from."
2093
2093
  },
2094
2094
  types: null
2095
2095
  },
@@ -5732,10 +5732,10 @@ function createShopClient(options = {}) {
5732
5732
  }
5733
5733
 
5734
5734
  // src/contract-hash.ts
5735
- var CONTRACT_SHA256 = "05f34929e71fb2fcb3a4c04707facca22ee46f8960a4cc47ce0a3f1a6df36056";
5735
+ var CONTRACT_SHA256 = "32f132210ee188c28a330c9db5c6db6eaf5b7c3a65ecc041e029aca6e1335a60";
5736
5736
 
5737
5737
  // src/client/diagnose.ts
5738
- var SDK_VERSION = "0.2.2" ;
5738
+ var SDK_VERSION = "0.3.0" ;
5739
5739
  async function resolveBaseUrl(options) {
5740
5740
  const provider = options.client?.baseUrl ?? options.baseUrl ?? SHOP_API_URL;
5741
5741
  const value = typeof provider === "function" ? await provider() : provider;
@@ -5827,6 +5827,104 @@ async function diagnoseShop(options = {}) {
5827
5827
  };
5828
5828
  }
5829
5829
 
5830
- export { CONTRACT_SHA256, SHOP_API_URL, ShopApiError, ShopConfigurationError, apiGroups, apiMountPrefixes, apiRoutes, apiRoutes_api, apiRoutes_app_info, apiRoutes_assigned_entitlements, apiRoutes_attribute_assignments, apiRoutes_attribute_categories, apiRoutes_attribute_options, apiRoutes_attributes, apiRoutes_b2b, apiRoutes_brands, apiRoutes_credits, apiRoutes_customers, apiRoutes_data_exchange, apiRoutes_designs, apiRoutes_discount_codes, apiRoutes_entitlement_limits, apiRoutes_entitlements, apiRoutes_events, apiRoutes_external_apps, apiRoutes_fulfillment, apiRoutes_iap, apiRoutes_invoices, apiRoutes_item_variants, apiRoutes_lager_inventory, apiRoutes_logs, apiRoutes_media_sets, apiRoutes_oauth2, apiRoutes_orders, apiRoutes_payments, apiRoutes_paypal, apiRoutes_permissions, apiRoutes_product_categories, apiRoutes_product_items, apiRoutes_products, apiRoutes_roles, apiRoutes_sender_brands, apiRoutes_settings, apiRoutes_status_changes, apiRoutes_stripe, apiRoutes_subscriptions, apiRoutes_suppliers, apiRoutes_tickets, apiRoutes_translations, apiRoutes_usage_reports, apiRoutes_user_activity, apiRoutes_users, apiRoutes_variant_entitlements, apiRoutes_webhooks, createShopClient, diagnoseShop };
5830
+ // src/capabilities.ts
5831
+ var SDK_VERSION2 = "0.3.0" ;
5832
+ var ROUTES = apiRoutes;
5833
+ var CLIENT_MANAGEMENT_OPS = [
5834
+ "external_apps_service_register",
5835
+ "external_apps_service_update",
5836
+ "external_apps_service_delete"
5837
+ ];
5838
+ var CLIENT_ROTATION_OPS = ["external_apps_service_rotate_key"];
5839
+ var PEER_STATUS_OPS = ["external_apps_service_status"];
5840
+ function has(operationId) {
5841
+ return Object.prototype.hasOwnProperty.call(ROUTES, operationId);
5842
+ }
5843
+ function capabilityFrom(operationIds, reasonWhenMissing) {
5844
+ const present = operationIds.filter(has);
5845
+ if (present.length === operationIds.length) {
5846
+ return { supported: true, operations: present };
5847
+ }
5848
+ const missing = operationIds.filter((id) => !present.includes(id));
5849
+ return {
5850
+ supported: false,
5851
+ operations: present,
5852
+ reason: `${reasonWhenMissing} Fehlend im Vertrag: ${missing.join(", ")}.`
5853
+ };
5854
+ }
5855
+ function capabilityFromPrefix(prefix, reasonWhenMissing) {
5856
+ const present = Object.keys(ROUTES).filter((id) => id.startsWith(prefix));
5857
+ return present.length > 0 ? { supported: true, operations: present } : { supported: false, operations: [], reason: reasonWhenMissing };
5858
+ }
5859
+ function shopCapabilities() {
5860
+ const operationIds = Object.keys(ROUTES);
5861
+ const authChannels = {};
5862
+ for (const id of operationIds) {
5863
+ const channel = ROUTES[id]?.auth?.type ?? "none";
5864
+ authChannels[channel] = (authChannels[channel] ?? 0) + 1;
5865
+ }
5866
+ return {
5867
+ service: "node-shop",
5868
+ sdkVersion: SDK_VERSION2,
5869
+ contractSha256: CONTRACT_SHA256,
5870
+ operationCount: operationIds.length,
5871
+ authChannels,
5872
+ capabilities: {
5873
+ // Der Endpunkt beschreibt den Vertrag und kann deshalb nicht in ihm stehen. Er
5874
+ // gehoert zur Zusage dieses SDK und wird von `diagnoseShop` live geprueft.
5875
+ contractFingerprint: { supported: true, operations: [] },
5876
+ healthCheck: capabilityFrom(
5877
+ ["app_info_health"],
5878
+ "Ohne Erreichbarkeits-Endpunkt bleibt nur der Umweg ueber eine echte Anfrage."
5879
+ ),
5880
+ clientManagement: capabilityFrom(
5881
+ CLIENT_MANAGEMENT_OPS,
5882
+ "Ohne diese Routen kann ein Verwalter keine Anbindung fuer andere Apps einrichten."
5883
+ ),
5884
+ clientRotation: capabilityFrom(
5885
+ CLIENT_ROTATION_OPS,
5886
+ "Ohne Erneuerung ist ein einmal ausgegebener Schluessel dauerhaft."
5887
+ ),
5888
+ // Anders als bei orvello haengt die Gnadenfrist nicht an eigenen Routen, sondern am
5889
+ // Feld `gracePeriodHours` derselben Rotation: der alte Schluessel bleibt so lange
5890
+ // gueltig und laeuft dann von selbst ab. Das ist eine Zusage des Vertrags, aber
5891
+ // keine, die sich anhand einer Operation belegen laesst — deshalb steht als Beleg
5892
+ // die Rotation selbst und nicht eine erfundene zweite Operation.
5893
+ rotationGracePeriod: has("external_apps_service_rotate_key") ? { supported: true, operations: CLIENT_ROTATION_OPS } : {
5894
+ supported: false,
5895
+ operations: [],
5896
+ reason: "Ohne Rotation gibt es auch keine Gnadenfrist."
5897
+ },
5898
+ clientRevocation: {
5899
+ supported: false,
5900
+ operations: [],
5901
+ reason: "node-shop kennt keinen eigenen Widerruf. Ein Zugang wird entzogen, indem die App auf `isActive: false` gesetzt (external_apps_service_update) oder geloescht wird (external_apps_service_delete) \u2014 das erste ist reversibel, das zweite endgueltig. Ein Verwalter, der nur den Schluessel ungueltig machen will, ohne die Anbindung anzufassen, hat dafuer heute keine Operation."
5902
+ },
5903
+ peerStatus: capabilityFrom(
5904
+ PEER_STATUS_OPS,
5905
+ "Ohne Statusroute kann ein Verwalter nur raten, was der Shop ueber die App fuehrt."
5906
+ ),
5907
+ entitlements: capabilityFromPrefix(
5908
+ "entitlements_",
5909
+ "Dieser Vertrag kennt keine Berechtigungs-Routen."
5910
+ ),
5911
+ commerce: capabilityFromPrefix(
5912
+ "b2b_",
5913
+ "Dieser Vertrag kennt keine B2B-Routen \u2014 fremde Apps koennen darueber nichts verkaufen."
5914
+ ),
5915
+ usageMetering: capabilityFromPrefix(
5916
+ "usage_reports_",
5917
+ "Dieser Vertrag kennt keine Verbrauchs-Routen."
5918
+ ),
5919
+ serverSideDryRun: {
5920
+ supported: false,
5921
+ operations: [],
5922
+ reason: "node-shop bietet keinen serverseitigen Probelauf an. Nebenwirkungsfrei pruefbar ist der Weg trotzdem: `diagnoseShop` beweist Erreichbarkeit und Vertrag ohne zu schreiben, und `external_apps_service_status` beweist, was der Shop ueber die App fuehrt \u2014 beides beweist die Voraussetzung, nicht das Ergebnis."
5923
+ }
5924
+ }
5925
+ };
5926
+ }
5927
+
5928
+ export { CONTRACT_SHA256, SHOP_API_URL, ShopApiError, ShopConfigurationError, apiGroups, apiMountPrefixes, apiRoutes, apiRoutes_api, apiRoutes_app_info, apiRoutes_assigned_entitlements, apiRoutes_attribute_assignments, apiRoutes_attribute_categories, apiRoutes_attribute_options, apiRoutes_attributes, apiRoutes_b2b, apiRoutes_brands, apiRoutes_credits, apiRoutes_customers, apiRoutes_data_exchange, apiRoutes_designs, apiRoutes_discount_codes, apiRoutes_entitlement_limits, apiRoutes_entitlements, apiRoutes_events, apiRoutes_external_apps, apiRoutes_fulfillment, apiRoutes_iap, apiRoutes_invoices, apiRoutes_item_variants, apiRoutes_lager_inventory, apiRoutes_logs, apiRoutes_media_sets, apiRoutes_oauth2, apiRoutes_orders, apiRoutes_payments, apiRoutes_paypal, apiRoutes_permissions, apiRoutes_product_categories, apiRoutes_product_items, apiRoutes_products, apiRoutes_roles, apiRoutes_sender_brands, apiRoutes_settings, apiRoutes_status_changes, apiRoutes_stripe, apiRoutes_subscriptions, apiRoutes_suppliers, apiRoutes_tickets, apiRoutes_translations, apiRoutes_usage_reports, apiRoutes_user_activity, apiRoutes_users, apiRoutes_variant_entitlements, apiRoutes_webhooks, createShopClient, diagnoseShop, shopCapabilities };
5831
5929
  //# sourceMappingURL=index.js.map
5832
5930
  //# sourceMappingURL=index.js.map