@stackable-labs/sdk-extension-contracts 1.63.0 → 1.65.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 +69 -39
- package/dist/index.js +4 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -324,6 +324,60 @@ 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
|
+
* Messaging Contract
|
|
329
|
+
* Types for the messaging event system (postback buttons, etc.).
|
|
330
|
+
*/
|
|
331
|
+
/** Messaging event subscription types — 'postback' for all, 'postback:<actionName>' for specific */
|
|
332
|
+
type MessagingEventType = 'postback' | `postback:${string}`;
|
|
333
|
+
/** Normalized postback event payload */
|
|
334
|
+
interface MessagingPostbackEvent {
|
|
335
|
+
type: 'postback';
|
|
336
|
+
actionName: string;
|
|
337
|
+
conversationId: string;
|
|
338
|
+
timestamp: string;
|
|
339
|
+
}
|
|
340
|
+
/** Union of all messaging events (extensible for future event types) */
|
|
341
|
+
type MessagingEvent = MessagingPostbackEvent;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Identity & Event Contract
|
|
345
|
+
* Types for the identity/auth event system and cross-domain event declarations.
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
type IdentityEventType = 'identity.login' | 'identity.logout' | 'identity.refresh' | 'identity.expired';
|
|
349
|
+
interface UserIdentity {
|
|
350
|
+
id: string;
|
|
351
|
+
email?: string;
|
|
352
|
+
name?: string;
|
|
353
|
+
avatarUrl?: string;
|
|
354
|
+
provider: string;
|
|
355
|
+
metadata?: Record<string, unknown>;
|
|
356
|
+
}
|
|
357
|
+
interface IdentityState {
|
|
358
|
+
authenticated: boolean;
|
|
359
|
+
user: UserIdentity | null;
|
|
360
|
+
expiresAt?: string;
|
|
361
|
+
}
|
|
362
|
+
interface IdentityEvent {
|
|
363
|
+
type: IdentityEventType;
|
|
364
|
+
state: IdentityState;
|
|
365
|
+
timestamp: string;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Union of all event types that can appear in the manifest events array.
|
|
369
|
+
* Grows as new event domains are added.
|
|
370
|
+
* Includes domain wildcards (e.g. 'identity' matches all identity.* events).
|
|
371
|
+
*/
|
|
372
|
+
type EventType = IdentityEventType | 'identity' | MessagingEventType | 'messaging';
|
|
373
|
+
/** Base claims sent to extend:identity handlers before JWT signing */
|
|
374
|
+
interface IdentityBaseClaims {
|
|
375
|
+
external_id: string;
|
|
376
|
+
email?: string;
|
|
377
|
+
name?: string;
|
|
378
|
+
[key: string]: unknown;
|
|
379
|
+
}
|
|
380
|
+
|
|
327
381
|
/**
|
|
328
382
|
* Capabilities Contract
|
|
329
383
|
* Defines the host-mediated APIs that extensions can call via RPC.
|
|
@@ -391,6 +445,8 @@ interface ContextData {
|
|
|
391
445
|
}
|
|
392
446
|
/** Union of all capability call types */
|
|
393
447
|
type CapabilityCall = {
|
|
448
|
+
type: 'context.read';
|
|
449
|
+
} | {
|
|
394
450
|
type: 'data.query';
|
|
395
451
|
payload: ApiRequest;
|
|
396
452
|
} | {
|
|
@@ -403,41 +459,13 @@ type CapabilityCall = {
|
|
|
403
459
|
type: 'actions.invoke';
|
|
404
460
|
payload: ActionInvokePayload;
|
|
405
461
|
} | {
|
|
406
|
-
type: '
|
|
407
|
-
} | {
|
|
408
|
-
type: 'identity.read';
|
|
409
|
-
} | {
|
|
410
|
-
type: 'identity.extend';
|
|
462
|
+
type: 'extend.identity';
|
|
411
463
|
payload: {
|
|
412
|
-
claims:
|
|
464
|
+
claims: IdentityBaseClaims;
|
|
413
465
|
};
|
|
414
466
|
};
|
|
415
467
|
type CapabilityType = CapabilityCall['type'];
|
|
416
468
|
|
|
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
469
|
/**
|
|
442
470
|
* Instance Contract
|
|
443
471
|
* Shared types for extension instances used by both host and admin.
|
|
@@ -464,7 +492,7 @@ interface InstanceOption {
|
|
|
464
492
|
* Extensions declare required permissions in their manifest.
|
|
465
493
|
* Host enforces: capability calls must be a subset of granted permissions.
|
|
466
494
|
*/
|
|
467
|
-
declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "identity
|
|
495
|
+
declare const PERMISSIONS: readonly ["context:read", "data:query", "data:fetch", "actions:toast", "actions:invoke", "events:identity", "events:messaging", "extend:identity"];
|
|
468
496
|
type Permission = (typeof PERMISSIONS)[number];
|
|
469
497
|
/**
|
|
470
498
|
* Maps capability types to the permission required to use them.
|
|
@@ -490,6 +518,8 @@ interface ExtensionManifest {
|
|
|
490
518
|
targets: string[];
|
|
491
519
|
/** Permissions required by this extension */
|
|
492
520
|
permissions: Permission[];
|
|
521
|
+
/** Specific events this extension listens for (e.g. ["identity.login", "postback:add_to_cart"]) */
|
|
522
|
+
events?: EventType[];
|
|
493
523
|
/**
|
|
494
524
|
* Hostnames this extension is permitted to reach via data.fetch.
|
|
495
525
|
* Example: ["api.myservice.com", "cdn.myservice.com"]
|
|
@@ -559,14 +589,14 @@ interface EncryptedPayload {
|
|
|
559
589
|
data: number[];
|
|
560
590
|
}
|
|
561
591
|
/** Host asks extension to enrich identity claims before signing */
|
|
562
|
-
interface
|
|
563
|
-
type: 'identity-
|
|
592
|
+
interface ExtendIdentityRequest {
|
|
593
|
+
type: 'extend-identity-request';
|
|
564
594
|
id: string;
|
|
565
|
-
claims:
|
|
595
|
+
claims: IdentityBaseClaims;
|
|
566
596
|
}
|
|
567
597
|
/** Extension responds with additional claims to merge into the JWT */
|
|
568
|
-
interface
|
|
569
|
-
type: 'identity-
|
|
598
|
+
interface ExtendIdentityResponse {
|
|
599
|
+
type: 'extend-identity-response';
|
|
570
600
|
id: string;
|
|
571
601
|
additionalClaims: Record<string, unknown>;
|
|
572
602
|
}
|
|
@@ -585,7 +615,7 @@ type HostToSandboxMessage = {
|
|
|
585
615
|
type: 'extension-event';
|
|
586
616
|
eventType: string;
|
|
587
617
|
payload: EncryptedPayload | unknown;
|
|
588
|
-
} |
|
|
618
|
+
} | ExtendIdentityRequest;
|
|
589
619
|
type SandboxToHostMessage = CapabilityRequest | {
|
|
590
620
|
type: 'surface-ready';
|
|
591
621
|
extensionId: string;
|
|
@@ -593,7 +623,7 @@ type SandboxToHostMessage = CapabilityRequest | {
|
|
|
593
623
|
} | {
|
|
594
624
|
type: 'extension-ready';
|
|
595
625
|
extensionId: string;
|
|
596
|
-
} |
|
|
626
|
+
} | ExtendIdentityResponse;
|
|
597
627
|
|
|
598
628
|
/**
|
|
599
629
|
* Ecommerce Type Definitions
|
|
@@ -831,4 +861,4 @@ interface Order {
|
|
|
831
861
|
display_status?: OrderStatus;
|
|
832
862
|
}
|
|
833
863
|
|
|
834
|
-
export { ALLOWED_ICONS, type ActionInvokePayload, type Address, type AllowedIconName, type ApiError, type ApiRequest, type ApiResponse,
|
|
864
|
+
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 EventType, 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 MessagingEvent, type MessagingEventType, type MessagingPostbackEvent, 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,9 @@ var PERMISSIONS = [
|
|
|
307
307
|
"data:fetch",
|
|
308
308
|
"actions:toast",
|
|
309
309
|
"actions:invoke",
|
|
310
|
-
"identity
|
|
311
|
-
"
|
|
312
|
-
"identity
|
|
310
|
+
"events:identity",
|
|
311
|
+
"events:messaging",
|
|
312
|
+
"extend:identity"
|
|
313
313
|
];
|
|
314
314
|
var CAPABILITY_PERMISSION_MAP = {
|
|
315
315
|
"context.read": "context:read",
|
|
@@ -317,8 +317,7 @@ var CAPABILITY_PERMISSION_MAP = {
|
|
|
317
317
|
"data.fetch": "data:fetch",
|
|
318
318
|
"actions.toast": "actions:toast",
|
|
319
319
|
"actions.invoke": "actions:invoke",
|
|
320
|
-
"identity
|
|
321
|
-
"identity.extend": "identity:extend"
|
|
320
|
+
"extend.identity": "extend:identity"
|
|
322
321
|
};
|
|
323
322
|
|
|
324
323
|
// ../../../lib/contracts/src/permissions.ts
|