@stackable-labs/sdk-extension-contracts 1.63.0 → 1.64.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.d.ts CHANGED
@@ -324,6 +324,37 @@ declare const tagToComponentName: (tag: UITag) => string;
324
324
  declare const ALLOWED_ICONS: readonly ["arrow-left", "calendar", "check-circle-2", "chevron-left", "chevron-right", "clock", "credit-card", "external-link", "help-circle", "info", "loader-2", "mail", "map-pin", "message-circle", "message-square", "package", "phone", "search", "shopping-bag", "sparkles", "truck", "user", "x-circle", "alert-circle", "book-open"];
325
325
  type AllowedIconName = (typeof ALLOWED_ICONS)[number];
326
326
 
327
+ /**
328
+ * Identity Contract
329
+ * Types for the identity/auth event system.
330
+ */
331
+ type IdentityEventType = 'identity.login' | 'identity.logout' | 'identity.refresh' | 'identity.expired';
332
+ interface UserIdentity {
333
+ id: string;
334
+ email?: string;
335
+ name?: string;
336
+ avatarUrl?: string;
337
+ provider: string;
338
+ metadata?: Record<string, unknown>;
339
+ }
340
+ interface IdentityState {
341
+ authenticated: boolean;
342
+ user: UserIdentity | null;
343
+ expiresAt?: string;
344
+ }
345
+ interface IdentityEvent {
346
+ type: IdentityEventType;
347
+ state: IdentityState;
348
+ timestamp: string;
349
+ }
350
+ /** Base claims sent to extend:identity handlers before JWT signing */
351
+ interface IdentityBaseClaims {
352
+ external_id: string;
353
+ email?: string;
354
+ name?: string;
355
+ [key: string]: unknown;
356
+ }
357
+
327
358
  /**
328
359
  * Capabilities Contract
329
360
  * Defines the host-mediated APIs that extensions can call via RPC.
@@ -391,6 +422,8 @@ interface ContextData {
391
422
  }
392
423
  /** Union of all capability call types */
393
424
  type CapabilityCall = {
425
+ type: 'context.read';
426
+ } | {
394
427
  type: 'data.query';
395
428
  payload: ApiRequest;
396
429
  } | {
@@ -403,41 +436,13 @@ type CapabilityCall = {
403
436
  type: 'actions.invoke';
404
437
  payload: ActionInvokePayload;
405
438
  } | {
406
- type: 'context.read';
407
- } | {
408
- type: 'identity.read';
409
- } | {
410
- type: 'identity.extend';
439
+ type: 'extend.identity';
411
440
  payload: {
412
- claims: Record<string, unknown>;
441
+ claims: IdentityBaseClaims;
413
442
  };
414
443
  };
415
444
  type CapabilityType = CapabilityCall['type'];
416
445
 
417
- /**
418
- * Identity Contract
419
- * Types for the identity/auth event system.
420
- */
421
- type AuthEventType = 'identity.login' | 'identity.logout' | 'identity.refresh' | 'identity.expired';
422
- interface UserIdentity {
423
- id: string;
424
- email?: string;
425
- name?: string;
426
- avatarUrl?: string;
427
- provider: string;
428
- metadata?: Record<string, unknown>;
429
- }
430
- interface AuthState {
431
- authenticated: boolean;
432
- user: UserIdentity | null;
433
- expiresAt?: string;
434
- }
435
- interface AuthEvent {
436
- type: AuthEventType;
437
- state: AuthState;
438
- timestamp: string;
439
- }
440
-
441
446
  /**
442
447
  * Instance Contract
443
448
  * Shared types for extension instances used by both host and admin.
@@ -464,7 +469,7 @@ interface InstanceOption {
464
469
  * Extensions declare required permissions in their manifest.
465
470
  * Host enforces: capability calls must be a subset of granted permissions.
466
471
  */
467
- declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "identity:read", "identity:subscribe", "identity:extend"];
472
+ declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "events:identity", "extend:identity"];
468
473
  type Permission = (typeof PERMISSIONS)[number];
469
474
  /**
470
475
  * Maps capability types to the permission required to use them.
@@ -490,6 +495,8 @@ interface ExtensionManifest {
490
495
  targets: string[];
491
496
  /** Permissions required by this extension */
492
497
  permissions: Permission[];
498
+ /** Specific events this extension listens for (e.g. ["identity.login", "postback:add_to_cart"]) */
499
+ events?: string[];
493
500
  /**
494
501
  * Hostnames this extension is permitted to reach via data.fetch.
495
502
  * Example: ["api.myservice.com", "cdn.myservice.com"]
@@ -559,14 +566,14 @@ interface EncryptedPayload {
559
566
  data: number[];
560
567
  }
561
568
  /** Host asks extension to enrich identity claims before signing */
562
- interface IdentityExtendRequest {
563
- type: 'identity-extend-request';
569
+ interface ExtendIdentityRequest {
570
+ type: 'extend-identity-request';
564
571
  id: string;
565
- claims: Record<string, unknown>;
572
+ claims: IdentityBaseClaims;
566
573
  }
567
574
  /** Extension responds with additional claims to merge into the JWT */
568
- interface IdentityExtendResponse {
569
- type: 'identity-extend-response';
575
+ interface ExtendIdentityResponse {
576
+ type: 'extend-identity-response';
570
577
  id: string;
571
578
  additionalClaims: Record<string, unknown>;
572
579
  }
@@ -585,7 +592,7 @@ type HostToSandboxMessage = {
585
592
  type: 'extension-event';
586
593
  eventType: string;
587
594
  payload: EncryptedPayload | unknown;
588
- } | IdentityExtendRequest;
595
+ } | ExtendIdentityRequest;
589
596
  type SandboxToHostMessage = CapabilityRequest | {
590
597
  type: 'surface-ready';
591
598
  extensionId: string;
@@ -593,7 +600,7 @@ type SandboxToHostMessage = CapabilityRequest | {
593
600
  } | {
594
601
  type: 'extension-ready';
595
602
  extensionId: string;
596
- } | IdentityExtendResponse;
603
+ } | ExtendIdentityResponse;
597
604
 
598
605
  /**
599
606
  * Ecommerce Type Definitions
@@ -831,4 +838,4 @@ interface Order {
831
838
  display_status?: OrderStatus;
832
839
  }
833
840
 
834
- export { ALLOWED_ICONS, type ActionInvokePayload, type Address, type AllowedIconName, type ApiError, type ApiRequest, type ApiResponse, type AuthEvent, type AuthEventType, type AuthState, CAPABILITY_PERMISSION_MAP, type CapabilityCall, type CapabilityRequest, type CapabilityResponse, type CapabilityType, type ContextData, type Customer, type DataField, type DataFieldType, type EncryptedPayload, type ExtensionManifest, type ExtensionRegistryEntry, type FetchRequest, type FetchRequestInit, type FetchResponse, type HostToSandboxMessage, type IdentityExtendRequest, type IdentityExtendResponse, type InstanceConfig, type InstanceOption, type InvokeAction, type MarketplaceExtension, type MessengerCommand, type NamedEntity, type Order, type OrderAction, type OrderItem, type OrderStatus, type OrderStatuses, PERMISSIONS, type Permission, type Price, type SandboxToHostMessage, type Shipment, type SurfaceContext, type SurfaceLifecycleMessage, type Target, type Theme, type ToastPayload, type UITag, type UITagCategory, UI_TAGS, UI_TAG_ATTRIBUTES, UI_TAG_ATTRIBUTE_VALUES, UI_TAG_CATEGORIES, UI_TAG_CHILDREN, UI_TAG_DEFINITIONS, type UserIdentity, type WidgetAction, tagToComponentName };
841
+ export { ALLOWED_ICONS, type ActionInvokePayload, type Address, type AllowedIconName, type ApiError, type ApiRequest, type ApiResponse, CAPABILITY_PERMISSION_MAP, type CapabilityCall, type CapabilityRequest, type CapabilityResponse, type CapabilityType, type ContextData, type Customer, type DataField, type DataFieldType, type EncryptedPayload, type ExtendIdentityRequest, type ExtendIdentityResponse, type ExtensionManifest, type ExtensionRegistryEntry, type FetchRequest, type FetchRequestInit, type FetchResponse, type HostToSandboxMessage, type IdentityBaseClaims, type IdentityEvent, type IdentityEventType, type IdentityState, type InstanceConfig, type InstanceOption, type InvokeAction, type MarketplaceExtension, type MessengerCommand, type NamedEntity, type Order, type OrderAction, type OrderItem, type OrderStatus, type OrderStatuses, PERMISSIONS, type Permission, type Price, type SandboxToHostMessage, type Shipment, type SurfaceContext, type SurfaceLifecycleMessage, type Target, type Theme, type ToastPayload, type UITag, type UITagCategory, UI_TAGS, UI_TAG_ATTRIBUTES, UI_TAG_ATTRIBUTE_VALUES, UI_TAG_CATEGORIES, UI_TAG_CHILDREN, UI_TAG_DEFINITIONS, type UserIdentity, type WidgetAction, tagToComponentName };
package/dist/index.js CHANGED
@@ -307,9 +307,8 @@ var PERMISSIONS = [
307
307
  "data:fetch",
308
308
  "actions:toast",
309
309
  "actions:invoke",
310
- "identity:read",
311
- "identity:subscribe",
312
- "identity:extend"
310
+ "events:identity",
311
+ "extend:identity"
313
312
  ];
314
313
  var CAPABILITY_PERMISSION_MAP = {
315
314
  "context.read": "context:read",
@@ -317,8 +316,7 @@ var CAPABILITY_PERMISSION_MAP = {
317
316
  "data.fetch": "data:fetch",
318
317
  "actions.toast": "actions:toast",
319
318
  "actions.invoke": "actions:invoke",
320
- "identity.read": "identity:read",
321
- "identity.extend": "identity:extend"
319
+ "extend.identity": "extend:identity"
322
320
  };
323
321
 
324
322
  // ../../../lib/contracts/src/permissions.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/sdk-extension-contracts",
3
- "version": "1.63.0",
3
+ "version": "1.64.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",