@wix/auto_sdk_duplexer_realtime-permissions-provider 1.0.2 → 1.0.4
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/build/cjs/index.d.ts +2 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/index.typings.d.ts +10 -36
- package/build/cjs/index.typings.js.map +1 -1
- package/build/cjs/{service-plugins-error-classes-mW1UQMcm.d.ts → service-plugins-error-classes-B7a57gue.d.ts} +41 -70
- package/build/es/index.d.mts +2 -2
- package/build/es/index.mjs.map +1 -1
- package/build/es/index.typings.d.mts +10 -36
- package/build/es/index.typings.mjs.map +1 -1
- package/build/es/{service-plugins-error-classes-mW1UQMcm.d.mts → service-plugins-error-classes-B7a57gue.d.mts} +41 -70
- package/build/internal/cjs/index.d.ts +2 -2
- package/build/internal/cjs/index.js.map +1 -1
- package/build/internal/cjs/index.typings.d.ts +10 -36
- package/build/internal/cjs/index.typings.js.map +1 -1
- package/build/internal/cjs/{service-plugins-error-classes-mW1UQMcm.d.ts → service-plugins-error-classes-B7a57gue.d.ts} +41 -70
- package/build/internal/es/index.d.mts +2 -2
- package/build/internal/es/index.mjs.map +1 -1
- package/build/internal/es/index.typings.d.mts +10 -36
- package/build/internal/es/index.typings.mjs.map +1 -1
- package/build/internal/es/{service-plugins-error-classes-mW1UQMcm.d.mts → service-plugins-error-classes-B7a57gue.d.mts} +41 -70
- package/package.json +2 -2
package/build/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as provideHandlers$1 } from './service-plugins-error-classes-
|
|
2
|
-
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, c as CheckSubscriberPermissionsResponse, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-
|
|
1
|
+
import { p as provideHandlers$1 } from './service-plugins-error-classes-B7a57gue.js';
|
|
2
|
+
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, c as CheckSubscriberPermissionsResponse, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-B7a57gue.js';
|
|
3
3
|
import { BuildServicePluginDefinition } from '@wix/sdk-types';
|
|
4
4
|
|
|
5
5
|
declare const provideHandlers: BuildServicePluginDefinition<typeof provideHandlers$1> & typeof provideHandlers$1;
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts","../../src/service-plugins-types.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.public.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.context.ts","../../src/service-plugins-error-classes.ts"],"sourcesContent":["export * from './src/service-plugins-types.js';\nexport * from './src/interfaces-realtime-v1-realtime-permissions-provider.context.js';\nexport * from './src/service-plugins-error-classes.js';\n","/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /** Realtime **channel** being subscribed to, including its logical name and optional resource scope. */\n channel?: Channel;\n /** *Subscriber** attempting the subscription (user id pattern depends on `type`; see `Subscriber.id`). */\n subscriber?: Subscriber;\n /**\n * App definition ID of the **caller's origin app** for this subscription check,\n * as injected by the Wix host from request identity context (not copied from the\n * duplexer `CheckPermissions` body). Identifies which third-party app is trying to\n * subscribe when that context exists.\n *\n * The host **always sets** this field on the wire. When the context has no origin\n * app id, the value may be an **empty string**—treat that as \"unknown origin app\"\n * rather than assuming a valid GUID.\n *\n * When non-empty, the value is a GUID string.\n * @format GUID\n */\n requestingAppId?: string | null;\n}\n\nexport interface Channel {\n /**\n * Logical channel name (for example, the name your app uses when publishing). Max 140 characters.\n * @maxLength 140\n */\n name?: string;\n /**\n * Optional id for a **resource** this channel is tied to (for example, a specific entity instance).\n * Use with `name` when multiple channels share the same name but differ by resource.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface Subscriber {\n /**\n * Stable identifier for the subscriber when one exists in context (e.g. Wix user id\n * for `ADMIN` / `MEMBER`). For `VISITOR`, the host may send an anonymous or empty\n * identifier depending on platform context—do not assume a real member id.\n * @maxLength 1000\n */\n _id?: string;\n /** The type of subscriber */\n type?: SubscriberType;\n}\n\nexport enum SubscriberType {\n SUBSCRIBER_TYPE_UNSPECIFIED = 'SUBSCRIBER_TYPE_UNSPECIFIED',\n /** Subscriber is the site owner */\n ADMIN = 'ADMIN',\n /** Subscriber is a logged-in site member */\n MEMBER = 'MEMBER',\n /** Subscriber is not logged in */\n VISITOR = 'VISITOR',\n}\n\n/** Response containing the subscriber's permissions for the channel. */\nexport interface CheckSubscriberPermissionsResponse {\n /** When `true`, the subscriber may **receive** messages published on the channel. */\n read?: boolean;\n /** When `true`, the subscriber may **send** client events on the channel. */\n write?: boolean;\n}\n\nexport interface RealtimePermissionsProviderConfig {\n /** Base URI where Wix should reach your service plugin **HTTPS** endpoints (see Auto SDK / SPI hosting). */\n deploymentUri?: SpiBaseUri;\n /**\n * Display name for this permissions provider in the app dashboard (translatable short text).\n * @maxLength 100\n */\n providerName?: string;\n}\n\nexport interface SpiBaseUri {\n /**\n * Base URI where the methods are called. Wix appends the path to the `baseUri`.\n * For example, to call the Get Shipping Rates method at `https://my-shipping-provider.com/v1/getRates`, the base URI you provide here is `https://my-shipping-provider.com/`.\n * @minLength 6\n * @maxLength 2048\n */\n baseUri?: string;\n /** Alternate, custom URIs to replace the default URIs for specific service plugin methods. */\n alternativeUris?: AlternativeUri[];\n}\n\nexport interface AlternativeUri {\n /**\n * Name of the method to create a custom URI for.\n *\n * For `methodName`, use the name of the method in PascalCase.\n * For example, for Get Shipping Rates use `GetShippingRates`.\n * @minLength 3\n * @maxLength 128\n */\n methodName?: string;\n /**\n * Custom URI that Wix uses to call your server for this method. The path-suffix documented in the method will not be appended to this URI.\n * Must be a secured endpoint beginning with `https://`. For example, `https://www.my-shipping-provider.com/my-shipping-rates`.\n * @minLength 6\n * @maxLength 2048\n */\n absoluteUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n requestId?: string | null;\n /**\n * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n * @format CURRENCY\n */\n currency?: string | null;\n /** An object that describes the identity that triggered this request. */\n identity?: IdentificationData;\n /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n languages?: string[];\n /**\n * The service provider app's instance ID.\n * @format GUID\n */\n instanceId?: string | null;\n}\n\nexport enum IdentityType {\n UNKNOWN = 'UNKNOWN',\n ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n MEMBER = 'MEMBER',\n WIX_USER = 'WIX_USER',\n APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n /** @readonly */\n identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n}\n","import { ServicePluginDefinition } from '@wix/sdk-types';\nimport {\n Context,\n CheckSubscriberPermissionsRequest,\n CheckSubscriberPermissionsResponse,\n} from './service-plugins-types.js';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\n\nexport interface CheckSubscriberPermissionsEnvelope {\n request: CheckSubscriberPermissionsRequest;\n metadata: Context;\n}\n\nexport const provideHandlers = ServicePluginDefinition<{\n /**\n *\n * Requests whether a subscriber may **read** and **write** on a Wix Realtime channel.\n *\n * Wix calls this method when the realtime stack evaluates a **channel subscription**\n * (for example, when `wix-duplexer-sockets-server` resolves access for a client).\n * The call is **synchronous**: Wix waits for your response before allowing or denying\n * receive / send capabilities for that subscription attempt.\n *\n * Wix uses your `read` and `write` flags to decide whether the subscriber may\n * *receive channel messages** and **publish client events**, respectively.\n * Normal **authorization denials** should be expressed with `read` / `write`\n * set to `false`, not by throwing.\n *\n * If your implementation **throws**, times out, or the outbound call fails after Wix\n * has selected your app as the implementer, the **Realtime Permissions host** reports\n * *gRPC `UNAVAILABLE` / HTTP 503** to its caller. It does **not** return a\n * structured “reason” field for that failure mode. Keep handlers fast and avoid\n * blocking calls where possible.\n *\n * Wix may **skip** calling this RPC when there is no registered implementer for the\n * channel owner app (`NO_IMPLEMENTER`) or when required **MetaSite / identity**\n * context is missing (`MISSING_CONTEXT`); those outcomes are resolved entirely by the host.\n *\n * *Your implementation should:**\n * - Use `channel`, `subscriber`, and `requesting_app_id` (see field comments) to enforce your rules.\n * - Return `read` / `write` explicitly for every successful decision.\n *\n * *Error handling:** Return **`InvalidArgumentError`** only when the **request payload**\n * is invalid for your implementation (for example, a channel or subscriber shape you\n * cannot interpret). Do **not** use that error for normal policy denials.\n *\n * Parameter: `CheckSubscriberPermissionsRequest`.\n * Response: `CheckSubscriberPermissionsResponse` — for example:\n * ```json\n * {\n * \"read\": true,\n * \"write\": false\n * }\n * ``` */\n checkSubscriberPermissions(\n payload: CheckSubscriberPermissionsEnvelope\n ):\n | CheckSubscriberPermissionsResponse\n | Promise<CheckSubscriberPermissionsResponse>;\n}>('REALTIME_PERMISSIONS_PROVIDER', [\n {\n name: 'checkSubscriberPermissions',\n primaryHttpMappingPath: '/v1/check-subscriber-permissions',\n transformations: {\n toREST: (payload: any) => {\n const toRestResponse = payload;\n\n return renameKeysFromSDKRequestToRESTRequest(toRestResponse);\n },\n fromREST: (payload: any) => {\n const fromRestRequest = payload;\n\n return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n },\n },\n },\n]);\n","import './interfaces-realtime-v1-realtime-permissions-provider.public.js';\nimport { createServicePluginModule } from '@wix/sdk-runtime/service-plugin-modules';\nimport { BuildServicePluginDefinition } from '@wix/sdk-types';\nimport { provideHandlers as publicProvideHandlers } from './interfaces-realtime-v1-realtime-permissions-provider.public.js';\n\nexport { publicProvideHandlers };\n\nexport const provideHandlers: BuildServicePluginDefinition<\n typeof publicProvideHandlers\n> &\n typeof publicProvideHandlers = createServicePluginModule(\n publicProvideHandlers\n);\n","export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAAA;AAAA,EAAA;AAAA;AAAA;;;ACgDO,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,iCAA8B;AAE9B,EAAAA,gBAAA,WAAQ;AAER,EAAAA,gBAAA,YAAS;AAET,EAAAA,gBAAA,aAAU;AAPA,SAAAA;AAAA,GAAA;AA2FL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;;;AC3IZ,uBAAwC;AAMxC,oCAGO;AAOA,IAAM,sBAAkB,0CA8C5B,iCAAiC;AAAA,EAClC;AAAA,IACE,MAAM;AAAA,IACN,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,MACf,QAAQ,CAAC,YAAiB;AACxB,cAAM,iBAAiB;AAEvB,mBAAO,qEAAsC,cAAc;AAAA,MAC7D;AAAA,MACA,UAAU,CAAC,YAAiB;AAC1B,cAAM,kBAAkB;AAExB,mBAAO,uEAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;AC9ED,oCAA0C;AAMnC,IAAMC,uBAGoB;AAAA,EAC/B;AACF;;;ACZO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAcjD,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,EACF;AAIF;AAAA;AA9Ba,wBA6BK,SAAS;","names":["provideHandlers","SubscriberType","IdentityType","provideHandlers"]}
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../src/service-plugins-types.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.public.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.context.ts","../../src/service-plugins-error-classes.ts"],"sourcesContent":["export * from './src/service-plugins-types.js';\nexport * from './src/interfaces-realtime-v1-realtime-permissions-provider.context.js';\nexport * from './src/service-plugins-error-classes.js';\n","/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /** [Channel or resource](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#channels-and-channel-resources) that the subscriber is attempting to join. */\n channel?: Channel;\n /** [Subscriber](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/subscriber/introduction) attempting the subscription. */\n subscriber?: Subscriber;\n /**\n * ID of the app attempting the [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions). When empty, the app context is unavailable.\n * @format GUID\n */\n requestingAppId?: string | null;\n}\n\n/** Realtime broadcast channel. Publishers send messages to channels and subscribers listen to them. */\nexport interface Channel {\n /**\n * Channel name. Supports only alphanumeric characters, hyphens, and underscores.\n * @maxLength 140\n */\n name?: string;\n /**\n * Resource ID. Resources are independent sub-channels within a channel.\n * A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** Subscriber to a channel or resource. */\nexport interface Subscriber {\n /**\n * Subscriber ID.\n * @maxLength 1000\n */\n _id?: string;\n /**\n * Subscriber identity type.\n *\n * Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities).\n */\n type?: SubscriberType;\n}\n\n/** Subscriber identity type. Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities). */\nexport enum SubscriberType {\n /** Unknown subscriber type. */\n SUBSCRIBER_TYPE_UNSPECIFIED = 'SUBSCRIBER_TYPE_UNSPECIFIED',\n /** [Wix user](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#wix-user). */\n ADMIN = 'ADMIN',\n /** Logged-in [site member](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#member). */\n MEMBER = 'MEMBER',\n /** [Site visitor](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#visitor). */\n VISITOR = 'VISITOR',\n}\n\n/** Response containing the subscriber's permissions for the channel. */\nexport interface CheckSubscriberPermissionsResponse {\n /** Whether the subscriber may receive messages on the channel. */\n read?: boolean;\n}\n\n/** Configuration for the Realtime Permissions Provider service plugin. */\nexport interface RealtimePermissionsProviderConfig {\n /** URI configuration for this service plugin. Wix calls your service plugin methods at these URIs. */\n deploymentUri?: SpiBaseUri;\n /**\n * Display name for this permissions provider in the [app dashboard](https://dev.wix.com/docs/build-apps/develop-your-app/app-workspace/about-the-app-dashboard).\n * @maxLength 100\n */\n providerName?: string;\n}\n\n/** Base URI configuration for a service plugin. Wix uses these URIs to call your service plugin methods. */\nexport interface SpiBaseUri {\n /**\n * Base URI for your service plugin. Wix appends each method's path to this URI.\n *\n * For example, to receive requests at `https://my-app.com/v1/my-method`, set this field to `https://my-app.com/`.\n * @minLength 6\n * @maxLength 2048\n */\n baseUri?: string;\n /** Alternative URIs for specific methods. Use these to override the default URI for individual methods. */\n alternativeUris?: AlternativeUri[];\n}\n\n/** Custom URI for the specified service plugin method. */\nexport interface AlternativeUri {\n /**\n * Name of the method to call at the absolute URI, in PascalCase. For example, to call [Get Shipping Rates](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates) on an alternative URI, specify `GetShippingRates`.\n * @minLength 3\n * @maxLength 128\n */\n methodName?: string;\n /**\n * Absolute URI that Wix calls for this method. Wix doesn't append any path to this URI.\n *\n * The URI must begin with `https://`, such as `https://my-app.com/v1/my-custom-method`.\n * @minLength 6\n * @maxLength 2048\n */\n absoluteUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n requestId?: string | null;\n /**\n * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n * @format CURRENCY\n */\n currency?: string | null;\n /** An object that describes the identity that triggered this request. */\n identity?: IdentificationData;\n /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n languages?: string[];\n /**\n * The service provider app's instance ID.\n * @format GUID\n */\n instanceId?: string | null;\n}\n\nexport enum IdentityType {\n UNKNOWN = 'UNKNOWN',\n ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n MEMBER = 'MEMBER',\n WIX_USER = 'WIX_USER',\n APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n /** @readonly */\n identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n}\n","import { ServicePluginDefinition } from '@wix/sdk-types';\nimport {\n Context,\n CheckSubscriberPermissionsRequest,\n CheckSubscriberPermissionsResponse,\n} from './service-plugins-types.js';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\n\nexport interface CheckSubscriberPermissionsEnvelope {\n request: CheckSubscriberPermissionsRequest;\n metadata: Context;\n}\n\nexport const provideHandlers = ServicePluginDefinition<{\n /**\n *\n * Checks whether a subscriber has permission to receive messages on a Wix Realtime channel.\n *\n * Wix calls this method when a subscriber from another app attempts a [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions) to one of your app's channels. The call is synchronous: Wix waits for your response before allowing or denying the subscription.\n *\n * To allow the subscriber to receive messages on the specified channel or resource, return `{ read: true }`. To deny, return `{ read: false }`.\n *\n * Learn more about [the Realtime APIs](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction).\n *\n * Error handling:\n * - Don't throw an error for normal denials. Use `{ read: false }` instead.\n * - If your service throws an error, times out, or is unreachable, Wix denies the subscription with a 503 HTTP status code.\n * - Return `InvalidArgumentError` only when the request contains invalid or missing data that prevents your service from processing it. */\n checkSubscriberPermissions(\n payload: CheckSubscriberPermissionsEnvelope\n ):\n | CheckSubscriberPermissionsResponse\n | Promise<CheckSubscriberPermissionsResponse>;\n}>('REALTIME_PERMISSIONS_PROVIDER', [\n {\n name: 'checkSubscriberPermissions',\n primaryHttpMappingPath: '/v1/check-subscriber-permissions',\n transformations: {\n toREST: (payload: any) => {\n const toRestResponse = payload;\n\n return renameKeysFromSDKRequestToRESTRequest(toRestResponse);\n },\n fromREST: (payload: any) => {\n const fromRestRequest = payload;\n\n return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n },\n },\n },\n]);\n","import './interfaces-realtime-v1-realtime-permissions-provider.public.js';\nimport { createServicePluginModule } from '@wix/sdk-runtime/service-plugin-modules';\nimport { BuildServicePluginDefinition } from '@wix/sdk-types';\nimport { provideHandlers as publicProvideHandlers } from './interfaces-realtime-v1-realtime-permissions-provider.public.js';\n\nexport { publicProvideHandlers };\n\nexport const provideHandlers: BuildServicePluginDefinition<\n typeof publicProvideHandlers\n> &\n typeof publicProvideHandlers = createServicePluginModule(\n publicProvideHandlers\n);\n","export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAAA;AAAA,EAAA;AAAA;AAAA;;;AC4CO,IAAK,iBAAL,kBAAKC,oBAAL;AAEL,EAAAA,gBAAA,iCAA8B;AAE9B,EAAAA,gBAAA,WAAQ;AAER,EAAAA,gBAAA,YAAS;AAET,EAAAA,gBAAA,aAAU;AARA,SAAAA;AAAA,GAAA;AA4FL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;;;ACxIZ,uBAAwC;AAMxC,oCAGO;AAOA,IAAM,sBAAkB,0CAoB5B,iCAAiC;AAAA,EAClC;AAAA,IACE,MAAM;AAAA,IACN,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,MACf,QAAQ,CAAC,YAAiB;AACxB,cAAM,iBAAiB;AAEvB,mBAAO,qEAAsC,cAAc;AAAA,MAC7D;AAAA,MACA,UAAU,CAAC,YAAiB;AAC1B,cAAM,kBAAkB;AAExB,mBAAO,uEAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ACpDD,oCAA0C;AAMnC,IAAMC,uBAGoB;AAAA,EAC/B;AACF;;;ACZO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAcjD,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,EACF;AAIF;AAAA;AA9Ba,wBA6BK,SAAS;","names":["provideHandlers","SubscriberType","IdentityType","provideHandlers"]}
|
|
@@ -1,46 +1,20 @@
|
|
|
1
|
-
import { i as CheckSubscriberPermissionsEnvelope, c as CheckSubscriberPermissionsResponse } from './service-plugins-error-classes-
|
|
2
|
-
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-
|
|
1
|
+
import { i as CheckSubscriberPermissionsEnvelope, c as CheckSubscriberPermissionsResponse } from './service-plugins-error-classes-B7a57gue.js';
|
|
2
|
+
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-B7a57gue.js';
|
|
3
3
|
import '@wix/sdk-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Checks whether a subscriber has permission to receive messages on a Wix Realtime channel.
|
|
7
7
|
*
|
|
8
|
-
* Wix calls this method when
|
|
9
|
-
* (for example, when `wix-duplexer-sockets-server` resolves access for a client).
|
|
10
|
-
* The call is **synchronous**: Wix waits for your response before allowing or denying
|
|
11
|
-
* receive / send capabilities for that subscription attempt.
|
|
8
|
+
* Wix calls this method when a subscriber from another app attempts a [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions) to one of your app's channels. The call is synchronous: Wix waits for your response before allowing or denying the subscription.
|
|
12
9
|
*
|
|
13
|
-
*
|
|
14
|
-
* *receive channel messages** and **publish client events**, respectively.
|
|
15
|
-
* Normal **authorization denials** should be expressed with `read` / `write`
|
|
16
|
-
* set to `false`, not by throwing.
|
|
10
|
+
* To allow the subscriber to receive messages on the specified channel or resource, return `{ read: true }`. To deny, return `{ read: false }`.
|
|
17
11
|
*
|
|
18
|
-
*
|
|
19
|
-
* has selected your app as the implementer, the **Realtime Permissions host** reports
|
|
20
|
-
* *gRPC `UNAVAILABLE` / HTTP 503** to its caller. It does **not** return a
|
|
21
|
-
* structured “reason” field for that failure mode. Keep handlers fast and avoid
|
|
22
|
-
* blocking calls where possible.
|
|
12
|
+
* Learn more about [the Realtime APIs](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction).
|
|
23
13
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* *Your implementation should:**
|
|
29
|
-
* - Use `channel`, `subscriber`, and `requesting_app_id` (see field comments) to enforce your rules.
|
|
30
|
-
* - Return `read` / `write` explicitly for every successful decision.
|
|
31
|
-
*
|
|
32
|
-
* *Error handling:** Return **`InvalidArgumentError`** only when the **request payload**
|
|
33
|
-
* is invalid for your implementation (for example, a channel or subscriber shape you
|
|
34
|
-
* cannot interpret). Do **not** use that error for normal policy denials.
|
|
35
|
-
*
|
|
36
|
-
* Parameter: `CheckSubscriberPermissionsRequest`.
|
|
37
|
-
* Response: `CheckSubscriberPermissionsResponse` — for example:
|
|
38
|
-
* ```json
|
|
39
|
-
* {
|
|
40
|
-
* "read": true,
|
|
41
|
-
* "write": false
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
14
|
+
* Error handling:
|
|
15
|
+
* - Don't throw an error for normal denials. Use `{ read: false }` instead.
|
|
16
|
+
* - If your service throws an error, times out, or is unreachable, Wix denies the subscription with a 503 HTTP status code.
|
|
17
|
+
* - Return `InvalidArgumentError` only when the request contains invalid or missing data that prevents your service from processing it.
|
|
44
18
|
* @throws InvalidArgumentWixError
|
|
45
19
|
*/
|
|
46
20
|
declare function checkSubscriberPermissions(payload: CheckSubscriberPermissionsEnvelope): CheckSubscriberPermissionsResponse | Promise<CheckSubscriberPermissionsResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.typings.ts","../../src/service-plugins-error-classes.ts","../../src/service-plugins-types.ts"],"sourcesContent":["import { CheckSubscriberPermissionsResponse } from './src/service-plugins-types.js';\nimport { CheckSubscriberPermissionsEnvelope } from './src/interfaces-realtime-v1-realtime-permissions-provider.public.js';\n\nexport * from './src/service-plugins-error-classes';\nexport * from './src/service-plugins-types';\nexport { CheckSubscriberPermissionsEnvelope };\n\n/**\n * Requests whether a subscriber may **read** and **write** on a Wix Realtime channel.\n *\n * Wix calls this method when the realtime stack evaluates a **channel subscription**\n * (for example, when `wix-duplexer-sockets-server` resolves access for a client).\n * The call is **synchronous**: Wix waits for your response before allowing or denying\n * receive / send capabilities for that subscription attempt.\n *\n * Wix uses your `read` and `write` flags to decide whether the subscriber may\n * *receive channel messages** and **publish client events**, respectively.\n * Normal **authorization denials** should be expressed with `read` / `write`\n * set to `false`, not by throwing.\n *\n * If your implementation **throws**, times out, or the outbound call fails after Wix\n * has selected your app as the implementer, the **Realtime Permissions host** reports\n * *gRPC `UNAVAILABLE` / HTTP 503** to its caller. It does **not** return a\n * structured “reason” field for that failure mode. Keep handlers fast and avoid\n * blocking calls where possible.\n *\n * Wix may **skip** calling this RPC when there is no registered implementer for the\n * channel owner app (`NO_IMPLEMENTER`) or when required **MetaSite / identity**\n * context is missing (`MISSING_CONTEXT`); those outcomes are resolved entirely by the host.\n *\n * *Your implementation should:**\n * - Use `channel`, `subscriber`, and `requesting_app_id` (see field comments) to enforce your rules.\n * - Return `read` / `write` explicitly for every successful decision.\n *\n * *Error handling:** Return **`InvalidArgumentError`** only when the **request payload**\n * is invalid for your implementation (for example, a channel or subscriber shape you\n * cannot interpret). Do **not** use that error for normal policy denials.\n *\n * Parameter: `CheckSubscriberPermissionsRequest`.\n * Response: `CheckSubscriberPermissionsResponse` — for example:\n * ```json\n * {\n * \"read\": true,\n * \"write\": false\n * }\n * ```\n * @throws InvalidArgumentWixError\n */\nexport declare function checkSubscriberPermissions(\n payload: CheckSubscriberPermissionsEnvelope\n):\n | CheckSubscriberPermissionsResponse\n | Promise<CheckSubscriberPermissionsResponse>;\n","export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n","/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /** Realtime **channel** being subscribed to, including its logical name and optional resource scope. */\n channel?: Channel;\n /** *Subscriber** attempting the subscription (user id pattern depends on `type`; see `Subscriber.id`). */\n subscriber?: Subscriber;\n /**\n * App definition ID of the **caller's origin app** for this subscription check,\n * as injected by the Wix host from request identity context (not copied from the\n * duplexer `CheckPermissions` body). Identifies which third-party app is trying to\n * subscribe when that context exists.\n *\n * The host **always sets** this field on the wire. When the context has no origin\n * app id, the value may be an **empty string**—treat that as \"unknown origin app\"\n * rather than assuming a valid GUID.\n *\n * When non-empty, the value is a GUID string.\n * @format GUID\n */\n requestingAppId?: string | null;\n}\n\nexport interface Channel {\n /**\n * Logical channel name (for example, the name your app uses when publishing). Max 140 characters.\n * @maxLength 140\n */\n name?: string;\n /**\n * Optional id for a **resource** this channel is tied to (for example, a specific entity instance).\n * Use with `name` when multiple channels share the same name but differ by resource.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface Subscriber {\n /**\n * Stable identifier for the subscriber when one exists in context (e.g. Wix user id\n * for `ADMIN` / `MEMBER`). For `VISITOR`, the host may send an anonymous or empty\n * identifier depending on platform context—do not assume a real member id.\n * @maxLength 1000\n */\n _id?: string;\n /** The type of subscriber */\n type?: SubscriberType;\n}\n\nexport enum SubscriberType {\n SUBSCRIBER_TYPE_UNSPECIFIED = 'SUBSCRIBER_TYPE_UNSPECIFIED',\n /** Subscriber is the site owner */\n ADMIN = 'ADMIN',\n /** Subscriber is a logged-in site member */\n MEMBER = 'MEMBER',\n /** Subscriber is not logged in */\n VISITOR = 'VISITOR',\n}\n\n/** Response containing the subscriber's permissions for the channel. */\nexport interface CheckSubscriberPermissionsResponse {\n /** When `true`, the subscriber may **receive** messages published on the channel. */\n read?: boolean;\n /** When `true`, the subscriber may **send** client events on the channel. */\n write?: boolean;\n}\n\nexport interface RealtimePermissionsProviderConfig {\n /** Base URI where Wix should reach your service plugin **HTTPS** endpoints (see Auto SDK / SPI hosting). */\n deploymentUri?: SpiBaseUri;\n /**\n * Display name for this permissions provider in the app dashboard (translatable short text).\n * @maxLength 100\n */\n providerName?: string;\n}\n\nexport interface SpiBaseUri {\n /**\n * Base URI where the methods are called. Wix appends the path to the `baseUri`.\n * For example, to call the Get Shipping Rates method at `https://my-shipping-provider.com/v1/getRates`, the base URI you provide here is `https://my-shipping-provider.com/`.\n * @minLength 6\n * @maxLength 2048\n */\n baseUri?: string;\n /** Alternate, custom URIs to replace the default URIs for specific service plugin methods. */\n alternativeUris?: AlternativeUri[];\n}\n\nexport interface AlternativeUri {\n /**\n * Name of the method to create a custom URI for.\n *\n * For `methodName`, use the name of the method in PascalCase.\n * For example, for Get Shipping Rates use `GetShippingRates`.\n * @minLength 3\n * @maxLength 128\n */\n methodName?: string;\n /**\n * Custom URI that Wix uses to call your server for this method. The path-suffix documented in the method will not be appended to this URI.\n * Must be a secured endpoint beginning with `https://`. For example, `https://www.my-shipping-provider.com/my-shipping-rates`.\n * @minLength 6\n * @maxLength 2048\n */\n absoluteUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n requestId?: string | null;\n /**\n * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n * @format CURRENCY\n */\n currency?: string | null;\n /** An object that describes the identity that triggered this request. */\n identity?: IdentificationData;\n /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n languages?: string[];\n /**\n * The service provider app's instance ID.\n * @format GUID\n */\n instanceId?: string | null;\n}\n\nexport enum IdentityType {\n UNKNOWN = 'UNKNOWN',\n ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n MEMBER = 'MEMBER',\n WIX_USER = 'WIX_USER',\n APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n /** @readonly */\n identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAcjD,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,EACF;AAIF;AAAA;AA9Ba,wBA6BK,SAAS;;;ACmBpB,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,iCAA8B;AAE9B,EAAAA,gBAAA,WAAQ;AAER,EAAAA,gBAAA,YAAS;AAET,EAAAA,gBAAA,aAAU;AAPA,SAAAA;AAAA,GAAA;AA2FL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;","names":["SubscriberType","IdentityType"]}
|
|
1
|
+
{"version":3,"sources":["../../index.typings.ts","../../src/service-plugins-error-classes.ts","../../src/service-plugins-types.ts"],"sourcesContent":["import { CheckSubscriberPermissionsResponse } from './src/service-plugins-types.js';\nimport { CheckSubscriberPermissionsEnvelope } from './src/interfaces-realtime-v1-realtime-permissions-provider.public.js';\n\nexport * from './src/service-plugins-error-classes';\nexport * from './src/service-plugins-types';\nexport { CheckSubscriberPermissionsEnvelope };\n\n/**\n * Checks whether a subscriber has permission to receive messages on a Wix Realtime channel.\n *\n * Wix calls this method when a subscriber from another app attempts a [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions) to one of your app's channels. The call is synchronous: Wix waits for your response before allowing or denying the subscription.\n *\n * To allow the subscriber to receive messages on the specified channel or resource, return `{ read: true }`. To deny, return `{ read: false }`.\n *\n * Learn more about [the Realtime APIs](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction).\n *\n * Error handling:\n * - Don't throw an error for normal denials. Use `{ read: false }` instead.\n * - If your service throws an error, times out, or is unreachable, Wix denies the subscription with a 503 HTTP status code.\n * - Return `InvalidArgumentError` only when the request contains invalid or missing data that prevents your service from processing it.\n * @throws InvalidArgumentWixError\n */\nexport declare function checkSubscriberPermissions(\n payload: CheckSubscriberPermissionsEnvelope\n):\n | CheckSubscriberPermissionsResponse\n | Promise<CheckSubscriberPermissionsResponse>;\n","export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n","/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /** [Channel or resource](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#channels-and-channel-resources) that the subscriber is attempting to join. */\n channel?: Channel;\n /** [Subscriber](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/subscriber/introduction) attempting the subscription. */\n subscriber?: Subscriber;\n /**\n * ID of the app attempting the [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions). When empty, the app context is unavailable.\n * @format GUID\n */\n requestingAppId?: string | null;\n}\n\n/** Realtime broadcast channel. Publishers send messages to channels and subscribers listen to them. */\nexport interface Channel {\n /**\n * Channel name. Supports only alphanumeric characters, hyphens, and underscores.\n * @maxLength 140\n */\n name?: string;\n /**\n * Resource ID. Resources are independent sub-channels within a channel.\n * A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** Subscriber to a channel or resource. */\nexport interface Subscriber {\n /**\n * Subscriber ID.\n * @maxLength 1000\n */\n _id?: string;\n /**\n * Subscriber identity type.\n *\n * Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities).\n */\n type?: SubscriberType;\n}\n\n/** Subscriber identity type. Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities). */\nexport enum SubscriberType {\n /** Unknown subscriber type. */\n SUBSCRIBER_TYPE_UNSPECIFIED = 'SUBSCRIBER_TYPE_UNSPECIFIED',\n /** [Wix user](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#wix-user). */\n ADMIN = 'ADMIN',\n /** Logged-in [site member](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#member). */\n MEMBER = 'MEMBER',\n /** [Site visitor](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#visitor). */\n VISITOR = 'VISITOR',\n}\n\n/** Response containing the subscriber's permissions for the channel. */\nexport interface CheckSubscriberPermissionsResponse {\n /** Whether the subscriber may receive messages on the channel. */\n read?: boolean;\n}\n\n/** Configuration for the Realtime Permissions Provider service plugin. */\nexport interface RealtimePermissionsProviderConfig {\n /** URI configuration for this service plugin. Wix calls your service plugin methods at these URIs. */\n deploymentUri?: SpiBaseUri;\n /**\n * Display name for this permissions provider in the [app dashboard](https://dev.wix.com/docs/build-apps/develop-your-app/app-workspace/about-the-app-dashboard).\n * @maxLength 100\n */\n providerName?: string;\n}\n\n/** Base URI configuration for a service plugin. Wix uses these URIs to call your service plugin methods. */\nexport interface SpiBaseUri {\n /**\n * Base URI for your service plugin. Wix appends each method's path to this URI.\n *\n * For example, to receive requests at `https://my-app.com/v1/my-method`, set this field to `https://my-app.com/`.\n * @minLength 6\n * @maxLength 2048\n */\n baseUri?: string;\n /** Alternative URIs for specific methods. Use these to override the default URI for individual methods. */\n alternativeUris?: AlternativeUri[];\n}\n\n/** Custom URI for the specified service plugin method. */\nexport interface AlternativeUri {\n /**\n * Name of the method to call at the absolute URI, in PascalCase. For example, to call [Get Shipping Rates](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates) on an alternative URI, specify `GetShippingRates`.\n * @minLength 3\n * @maxLength 128\n */\n methodName?: string;\n /**\n * Absolute URI that Wix calls for this method. Wix doesn't append any path to this URI.\n *\n * The URI must begin with `https://`, such as `https://my-app.com/v1/my-custom-method`.\n * @minLength 6\n * @maxLength 2048\n */\n absoluteUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n requestId?: string | null;\n /**\n * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n * @format CURRENCY\n */\n currency?: string | null;\n /** An object that describes the identity that triggered this request. */\n identity?: IdentificationData;\n /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n languages?: string[];\n /**\n * The service provider app's instance ID.\n * @format GUID\n */\n instanceId?: string | null;\n}\n\nexport enum IdentityType {\n UNKNOWN = 'UNKNOWN',\n ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n MEMBER = 'MEMBER',\n WIX_USER = 'WIX_USER',\n APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n /** @readonly */\n identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAcjD,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,EACF;AAIF;AAAA;AA9Ba,wBA6BK,SAAS;;;ACepB,IAAK,iBAAL,kBAAKA,oBAAL;AAEL,EAAAA,gBAAA,iCAA8B;AAE9B,EAAAA,gBAAA,WAAQ;AAER,EAAAA,gBAAA,YAAS;AAET,EAAAA,gBAAA,aAAU;AARA,SAAAA;AAAA,GAAA;AA4FL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;","names":["SubscriberType","IdentityType"]}
|
|
@@ -2,98 +2,95 @@ import { ServicePluginDefinition } from '@wix/sdk-types';
|
|
|
2
2
|
|
|
3
3
|
/** Request to check subscriber permissions for a realtime channel. */
|
|
4
4
|
interface CheckSubscriberPermissionsRequest {
|
|
5
|
-
/**
|
|
5
|
+
/** [Channel or resource](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#channels-and-channel-resources) that the subscriber is attempting to join. */
|
|
6
6
|
channel?: Channel;
|
|
7
|
-
/**
|
|
7
|
+
/** [Subscriber](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/subscriber/introduction) attempting the subscription. */
|
|
8
8
|
subscriber?: Subscriber;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* as injected by the Wix host from request identity context (not copied from the
|
|
12
|
-
* duplexer `CheckPermissions` body). Identifies which third-party app is trying to
|
|
13
|
-
* subscribe when that context exists.
|
|
14
|
-
*
|
|
15
|
-
* The host **always sets** this field on the wire. When the context has no origin
|
|
16
|
-
* app id, the value may be an **empty string**—treat that as "unknown origin app"
|
|
17
|
-
* rather than assuming a valid GUID.
|
|
18
|
-
*
|
|
19
|
-
* When non-empty, the value is a GUID string.
|
|
10
|
+
* ID of the app attempting the [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions). When empty, the app context is unavailable.
|
|
20
11
|
* @format GUID
|
|
21
12
|
*/
|
|
22
13
|
requestingAppId?: string | null;
|
|
23
14
|
}
|
|
15
|
+
/** Realtime broadcast channel. Publishers send messages to channels and subscribers listen to them. */
|
|
24
16
|
interface Channel {
|
|
25
17
|
/**
|
|
26
|
-
*
|
|
18
|
+
* Channel name. Supports only alphanumeric characters, hyphens, and underscores.
|
|
27
19
|
* @maxLength 140
|
|
28
20
|
*/
|
|
29
21
|
name?: string;
|
|
30
22
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
23
|
+
* Resource ID. Resources are independent sub-channels within a channel.
|
|
24
|
+
* A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa.
|
|
33
25
|
* @maxLength 1000
|
|
34
26
|
*/
|
|
35
27
|
resourceId?: string | null;
|
|
36
28
|
}
|
|
29
|
+
/** Subscriber to a channel or resource. */
|
|
37
30
|
interface Subscriber {
|
|
38
31
|
/**
|
|
39
|
-
*
|
|
40
|
-
* for `ADMIN` / `MEMBER`). For `VISITOR`, the host may send an anonymous or empty
|
|
41
|
-
* identifier depending on platform context—do not assume a real member id.
|
|
32
|
+
* Subscriber ID.
|
|
42
33
|
* @maxLength 1000
|
|
43
34
|
*/
|
|
44
35
|
_id?: string;
|
|
45
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Subscriber identity type.
|
|
38
|
+
*
|
|
39
|
+
* Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities).
|
|
40
|
+
*/
|
|
46
41
|
type?: SubscriberType;
|
|
47
42
|
}
|
|
43
|
+
/** Subscriber identity type. Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities). */
|
|
48
44
|
declare enum SubscriberType {
|
|
45
|
+
/** Unknown subscriber type. */
|
|
49
46
|
SUBSCRIBER_TYPE_UNSPECIFIED = "SUBSCRIBER_TYPE_UNSPECIFIED",
|
|
50
|
-
/**
|
|
47
|
+
/** [Wix user](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#wix-user). */
|
|
51
48
|
ADMIN = "ADMIN",
|
|
52
|
-
/**
|
|
49
|
+
/** Logged-in [site member](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#member). */
|
|
53
50
|
MEMBER = "MEMBER",
|
|
54
|
-
/**
|
|
51
|
+
/** [Site visitor](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#visitor). */
|
|
55
52
|
VISITOR = "VISITOR"
|
|
56
53
|
}
|
|
57
54
|
/** Response containing the subscriber's permissions for the channel. */
|
|
58
55
|
interface CheckSubscriberPermissionsResponse {
|
|
59
|
-
/**
|
|
56
|
+
/** Whether the subscriber may receive messages on the channel. */
|
|
60
57
|
read?: boolean;
|
|
61
|
-
/** When `true`, the subscriber may **send** client events on the channel. */
|
|
62
|
-
write?: boolean;
|
|
63
58
|
}
|
|
59
|
+
/** Configuration for the Realtime Permissions Provider service plugin. */
|
|
64
60
|
interface RealtimePermissionsProviderConfig {
|
|
65
|
-
/**
|
|
61
|
+
/** URI configuration for this service plugin. Wix calls your service plugin methods at these URIs. */
|
|
66
62
|
deploymentUri?: SpiBaseUri;
|
|
67
63
|
/**
|
|
68
|
-
* Display name for this permissions provider in the app dashboard
|
|
64
|
+
* Display name for this permissions provider in the [app dashboard](https://dev.wix.com/docs/build-apps/develop-your-app/app-workspace/about-the-app-dashboard).
|
|
69
65
|
* @maxLength 100
|
|
70
66
|
*/
|
|
71
67
|
providerName?: string;
|
|
72
68
|
}
|
|
69
|
+
/** Base URI configuration for a service plugin. Wix uses these URIs to call your service plugin methods. */
|
|
73
70
|
interface SpiBaseUri {
|
|
74
71
|
/**
|
|
75
|
-
* Base URI
|
|
76
|
-
*
|
|
72
|
+
* Base URI for your service plugin. Wix appends each method's path to this URI.
|
|
73
|
+
*
|
|
74
|
+
* For example, to receive requests at `https://my-app.com/v1/my-method`, set this field to `https://my-app.com/`.
|
|
77
75
|
* @minLength 6
|
|
78
76
|
* @maxLength 2048
|
|
79
77
|
*/
|
|
80
78
|
baseUri?: string;
|
|
81
|
-
/**
|
|
79
|
+
/** Alternative URIs for specific methods. Use these to override the default URI for individual methods. */
|
|
82
80
|
alternativeUris?: AlternativeUri[];
|
|
83
81
|
}
|
|
82
|
+
/** Custom URI for the specified service plugin method. */
|
|
84
83
|
interface AlternativeUri {
|
|
85
84
|
/**
|
|
86
|
-
* Name of the method to
|
|
87
|
-
*
|
|
88
|
-
* For `methodName`, use the name of the method in PascalCase.
|
|
89
|
-
* For example, for Get Shipping Rates use `GetShippingRates`.
|
|
85
|
+
* Name of the method to call at the absolute URI, in PascalCase. For example, to call [Get Shipping Rates](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates) on an alternative URI, specify `GetShippingRates`.
|
|
90
86
|
* @minLength 3
|
|
91
87
|
* @maxLength 128
|
|
92
88
|
*/
|
|
93
89
|
methodName?: string;
|
|
94
90
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
91
|
+
* Absolute URI that Wix calls for this method. Wix doesn't append any path to this URI.
|
|
92
|
+
*
|
|
93
|
+
* The URI must begin with `https://`, such as `https://my-app.com/v1/my-custom-method`.
|
|
97
94
|
* @minLength 6
|
|
98
95
|
* @maxLength 2048
|
|
99
96
|
*/
|
|
@@ -192,44 +189,18 @@ interface CheckSubscriberPermissionsEnvelope {
|
|
|
192
189
|
declare const provideHandlers: ServicePluginDefinition<{
|
|
193
190
|
/**
|
|
194
191
|
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* Wix calls this method when the realtime stack evaluates a **channel subscription**
|
|
198
|
-
* (for example, when `wix-duplexer-sockets-server` resolves access for a client).
|
|
199
|
-
* The call is **synchronous**: Wix waits for your response before allowing or denying
|
|
200
|
-
* receive / send capabilities for that subscription attempt.
|
|
201
|
-
*
|
|
202
|
-
* Wix uses your `read` and `write` flags to decide whether the subscriber may
|
|
203
|
-
* *receive channel messages** and **publish client events**, respectively.
|
|
204
|
-
* Normal **authorization denials** should be expressed with `read` / `write`
|
|
205
|
-
* set to `false`, not by throwing.
|
|
206
|
-
*
|
|
207
|
-
* If your implementation **throws**, times out, or the outbound call fails after Wix
|
|
208
|
-
* has selected your app as the implementer, the **Realtime Permissions host** reports
|
|
209
|
-
* *gRPC `UNAVAILABLE` / HTTP 503** to its caller. It does **not** return a
|
|
210
|
-
* structured “reason” field for that failure mode. Keep handlers fast and avoid
|
|
211
|
-
* blocking calls where possible.
|
|
192
|
+
* Checks whether a subscriber has permission to receive messages on a Wix Realtime channel.
|
|
212
193
|
*
|
|
213
|
-
* Wix
|
|
214
|
-
* channel owner app (`NO_IMPLEMENTER`) or when required **MetaSite / identity**
|
|
215
|
-
* context is missing (`MISSING_CONTEXT`); those outcomes are resolved entirely by the host.
|
|
194
|
+
* Wix calls this method when a subscriber from another app attempts a [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions) to one of your app's channels. The call is synchronous: Wix waits for your response before allowing or denying the subscription.
|
|
216
195
|
*
|
|
217
|
-
*
|
|
218
|
-
* - Use `channel`, `subscriber`, and `requesting_app_id` (see field comments) to enforce your rules.
|
|
219
|
-
* - Return `read` / `write` explicitly for every successful decision.
|
|
196
|
+
* To allow the subscriber to receive messages on the specified channel or resource, return `{ read: true }`. To deny, return `{ read: false }`.
|
|
220
197
|
*
|
|
221
|
-
*
|
|
222
|
-
* is invalid for your implementation (for example, a channel or subscriber shape you
|
|
223
|
-
* cannot interpret). Do **not** use that error for normal policy denials.
|
|
198
|
+
* Learn more about [the Realtime APIs](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction).
|
|
224
199
|
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* "read": true,
|
|
230
|
-
* "write": false
|
|
231
|
-
* }
|
|
232
|
-
* ``` */
|
|
200
|
+
* Error handling:
|
|
201
|
+
* - Don't throw an error for normal denials. Use `{ read: false }` instead.
|
|
202
|
+
* - If your service throws an error, times out, or is unreachable, Wix denies the subscription with a 503 HTTP status code.
|
|
203
|
+
* - Return `InvalidArgumentError` only when the request contains invalid or missing data that prevents your service from processing it. */
|
|
233
204
|
checkSubscriberPermissions(payload: CheckSubscriberPermissionsEnvelope): CheckSubscriberPermissionsResponse | Promise<CheckSubscriberPermissionsResponse>;
|
|
234
205
|
}>;
|
|
235
206
|
|
package/build/es/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as provideHandlers$1 } from './service-plugins-error-classes-
|
|
2
|
-
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, c as CheckSubscriberPermissionsResponse, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-
|
|
1
|
+
import { p as provideHandlers$1 } from './service-plugins-error-classes-B7a57gue.mjs';
|
|
2
|
+
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, c as CheckSubscriberPermissionsResponse, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-B7a57gue.mjs';
|
|
3
3
|
import { BuildServicePluginDefinition } from '@wix/sdk-types';
|
|
4
4
|
|
|
5
5
|
declare const provideHandlers: BuildServicePluginDefinition<typeof provideHandlers$1> & typeof provideHandlers$1;
|
package/build/es/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/service-plugins-types.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.public.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.context.ts","../../src/service-plugins-error-classes.ts"],"sourcesContent":["/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /** Realtime **channel** being subscribed to, including its logical name and optional resource scope. */\n channel?: Channel;\n /** *Subscriber** attempting the subscription (user id pattern depends on `type`; see `Subscriber.id`). */\n subscriber?: Subscriber;\n /**\n * App definition ID of the **caller's origin app** for this subscription check,\n * as injected by the Wix host from request identity context (not copied from the\n * duplexer `CheckPermissions` body). Identifies which third-party app is trying to\n * subscribe when that context exists.\n *\n * The host **always sets** this field on the wire. When the context has no origin\n * app id, the value may be an **empty string**—treat that as \"unknown origin app\"\n * rather than assuming a valid GUID.\n *\n * When non-empty, the value is a GUID string.\n * @format GUID\n */\n requestingAppId?: string | null;\n}\n\nexport interface Channel {\n /**\n * Logical channel name (for example, the name your app uses when publishing). Max 140 characters.\n * @maxLength 140\n */\n name?: string;\n /**\n * Optional id for a **resource** this channel is tied to (for example, a specific entity instance).\n * Use with `name` when multiple channels share the same name but differ by resource.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface Subscriber {\n /**\n * Stable identifier for the subscriber when one exists in context (e.g. Wix user id\n * for `ADMIN` / `MEMBER`). For `VISITOR`, the host may send an anonymous or empty\n * identifier depending on platform context—do not assume a real member id.\n * @maxLength 1000\n */\n _id?: string;\n /** The type of subscriber */\n type?: SubscriberType;\n}\n\nexport enum SubscriberType {\n SUBSCRIBER_TYPE_UNSPECIFIED = 'SUBSCRIBER_TYPE_UNSPECIFIED',\n /** Subscriber is the site owner */\n ADMIN = 'ADMIN',\n /** Subscriber is a logged-in site member */\n MEMBER = 'MEMBER',\n /** Subscriber is not logged in */\n VISITOR = 'VISITOR',\n}\n\n/** Response containing the subscriber's permissions for the channel. */\nexport interface CheckSubscriberPermissionsResponse {\n /** When `true`, the subscriber may **receive** messages published on the channel. */\n read?: boolean;\n /** When `true`, the subscriber may **send** client events on the channel. */\n write?: boolean;\n}\n\nexport interface RealtimePermissionsProviderConfig {\n /** Base URI where Wix should reach your service plugin **HTTPS** endpoints (see Auto SDK / SPI hosting). */\n deploymentUri?: SpiBaseUri;\n /**\n * Display name for this permissions provider in the app dashboard (translatable short text).\n * @maxLength 100\n */\n providerName?: string;\n}\n\nexport interface SpiBaseUri {\n /**\n * Base URI where the methods are called. Wix appends the path to the `baseUri`.\n * For example, to call the Get Shipping Rates method at `https://my-shipping-provider.com/v1/getRates`, the base URI you provide here is `https://my-shipping-provider.com/`.\n * @minLength 6\n * @maxLength 2048\n */\n baseUri?: string;\n /** Alternate, custom URIs to replace the default URIs for specific service plugin methods. */\n alternativeUris?: AlternativeUri[];\n}\n\nexport interface AlternativeUri {\n /**\n * Name of the method to create a custom URI for.\n *\n * For `methodName`, use the name of the method in PascalCase.\n * For example, for Get Shipping Rates use `GetShippingRates`.\n * @minLength 3\n * @maxLength 128\n */\n methodName?: string;\n /**\n * Custom URI that Wix uses to call your server for this method. The path-suffix documented in the method will not be appended to this URI.\n * Must be a secured endpoint beginning with `https://`. For example, `https://www.my-shipping-provider.com/my-shipping-rates`.\n * @minLength 6\n * @maxLength 2048\n */\n absoluteUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n requestId?: string | null;\n /**\n * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n * @format CURRENCY\n */\n currency?: string | null;\n /** An object that describes the identity that triggered this request. */\n identity?: IdentificationData;\n /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n languages?: string[];\n /**\n * The service provider app's instance ID.\n * @format GUID\n */\n instanceId?: string | null;\n}\n\nexport enum IdentityType {\n UNKNOWN = 'UNKNOWN',\n ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n MEMBER = 'MEMBER',\n WIX_USER = 'WIX_USER',\n APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n /** @readonly */\n identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n}\n","import { ServicePluginDefinition } from '@wix/sdk-types';\nimport {\n Context,\n CheckSubscriberPermissionsRequest,\n CheckSubscriberPermissionsResponse,\n} from './service-plugins-types.js';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\n\nexport interface CheckSubscriberPermissionsEnvelope {\n request: CheckSubscriberPermissionsRequest;\n metadata: Context;\n}\n\nexport const provideHandlers = ServicePluginDefinition<{\n /**\n *\n * Requests whether a subscriber may **read** and **write** on a Wix Realtime channel.\n *\n * Wix calls this method when the realtime stack evaluates a **channel subscription**\n * (for example, when `wix-duplexer-sockets-server` resolves access for a client).\n * The call is **synchronous**: Wix waits for your response before allowing or denying\n * receive / send capabilities for that subscription attempt.\n *\n * Wix uses your `read` and `write` flags to decide whether the subscriber may\n * *receive channel messages** and **publish client events**, respectively.\n * Normal **authorization denials** should be expressed with `read` / `write`\n * set to `false`, not by throwing.\n *\n * If your implementation **throws**, times out, or the outbound call fails after Wix\n * has selected your app as the implementer, the **Realtime Permissions host** reports\n * *gRPC `UNAVAILABLE` / HTTP 503** to its caller. It does **not** return a\n * structured “reason” field for that failure mode. Keep handlers fast and avoid\n * blocking calls where possible.\n *\n * Wix may **skip** calling this RPC when there is no registered implementer for the\n * channel owner app (`NO_IMPLEMENTER`) or when required **MetaSite / identity**\n * context is missing (`MISSING_CONTEXT`); those outcomes are resolved entirely by the host.\n *\n * *Your implementation should:**\n * - Use `channel`, `subscriber`, and `requesting_app_id` (see field comments) to enforce your rules.\n * - Return `read` / `write` explicitly for every successful decision.\n *\n * *Error handling:** Return **`InvalidArgumentError`** only when the **request payload**\n * is invalid for your implementation (for example, a channel or subscriber shape you\n * cannot interpret). Do **not** use that error for normal policy denials.\n *\n * Parameter: `CheckSubscriberPermissionsRequest`.\n * Response: `CheckSubscriberPermissionsResponse` — for example:\n * ```json\n * {\n * \"read\": true,\n * \"write\": false\n * }\n * ``` */\n checkSubscriberPermissions(\n payload: CheckSubscriberPermissionsEnvelope\n ):\n | CheckSubscriberPermissionsResponse\n | Promise<CheckSubscriberPermissionsResponse>;\n}>('REALTIME_PERMISSIONS_PROVIDER', [\n {\n name: 'checkSubscriberPermissions',\n primaryHttpMappingPath: '/v1/check-subscriber-permissions',\n transformations: {\n toREST: (payload: any) => {\n const toRestResponse = payload;\n\n return renameKeysFromSDKRequestToRESTRequest(toRestResponse);\n },\n fromREST: (payload: any) => {\n const fromRestRequest = payload;\n\n return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n },\n },\n },\n]);\n","import './interfaces-realtime-v1-realtime-permissions-provider.public.js';\nimport { createServicePluginModule } from '@wix/sdk-runtime/service-plugin-modules';\nimport { BuildServicePluginDefinition } from '@wix/sdk-types';\nimport { provideHandlers as publicProvideHandlers } from './interfaces-realtime-v1-realtime-permissions-provider.public.js';\n\nexport { publicProvideHandlers };\n\nexport const provideHandlers: BuildServicePluginDefinition<\n typeof publicProvideHandlers\n> &\n typeof publicProvideHandlers = createServicePluginModule(\n publicProvideHandlers\n);\n","export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n"],"mappings":";AAgDO,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,iCAA8B;AAE9B,EAAAA,gBAAA,WAAQ;AAER,EAAAA,gBAAA,YAAS;AAET,EAAAA,gBAAA,aAAU;AAPA,SAAAA;AAAA,GAAA;AA2FL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;;;AC3IZ,SAAS,+BAA+B;AAMxC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOA,IAAM,kBAAkB,wBA8C5B,iCAAiC;AAAA,EAClC;AAAA,IACE,MAAM;AAAA,IACN,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,MACf,QAAQ,CAAC,YAAiB;AACxB,cAAM,iBAAiB;AAEvB,eAAO,sCAAsC,cAAc;AAAA,MAC7D;AAAA,MACA,UAAU,CAAC,YAAiB;AAC1B,cAAM,kBAAkB;AAExB,eAAO,wCAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;AC9ED,SAAS,iCAAiC;AAMnC,IAAMC,mBAGoB;AAAA,EAC/B;AACF;;;ACZO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAcjD,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,EACF;AAIF;AAAA;AA9Ba,wBA6BK,SAAS;","names":["SubscriberType","IdentityType","provideHandlers"]}
|
|
1
|
+
{"version":3,"sources":["../../src/service-plugins-types.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.public.ts","../../src/interfaces-realtime-v1-realtime-permissions-provider.context.ts","../../src/service-plugins-error-classes.ts"],"sourcesContent":["/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /** [Channel or resource](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#channels-and-channel-resources) that the subscriber is attempting to join. */\n channel?: Channel;\n /** [Subscriber](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/subscriber/introduction) attempting the subscription. */\n subscriber?: Subscriber;\n /**\n * ID of the app attempting the [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions). When empty, the app context is unavailable.\n * @format GUID\n */\n requestingAppId?: string | null;\n}\n\n/** Realtime broadcast channel. Publishers send messages to channels and subscribers listen to them. */\nexport interface Channel {\n /**\n * Channel name. Supports only alphanumeric characters, hyphens, and underscores.\n * @maxLength 140\n */\n name?: string;\n /**\n * Resource ID. Resources are independent sub-channels within a channel.\n * A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** Subscriber to a channel or resource. */\nexport interface Subscriber {\n /**\n * Subscriber ID.\n * @maxLength 1000\n */\n _id?: string;\n /**\n * Subscriber identity type.\n *\n * Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities).\n */\n type?: SubscriberType;\n}\n\n/** Subscriber identity type. Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities). */\nexport enum SubscriberType {\n /** Unknown subscriber type. */\n SUBSCRIBER_TYPE_UNSPECIFIED = 'SUBSCRIBER_TYPE_UNSPECIFIED',\n /** [Wix user](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#wix-user). */\n ADMIN = 'ADMIN',\n /** Logged-in [site member](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#member). */\n MEMBER = 'MEMBER',\n /** [Site visitor](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#visitor). */\n VISITOR = 'VISITOR',\n}\n\n/** Response containing the subscriber's permissions for the channel. */\nexport interface CheckSubscriberPermissionsResponse {\n /** Whether the subscriber may receive messages on the channel. */\n read?: boolean;\n}\n\n/** Configuration for the Realtime Permissions Provider service plugin. */\nexport interface RealtimePermissionsProviderConfig {\n /** URI configuration for this service plugin. Wix calls your service plugin methods at these URIs. */\n deploymentUri?: SpiBaseUri;\n /**\n * Display name for this permissions provider in the [app dashboard](https://dev.wix.com/docs/build-apps/develop-your-app/app-workspace/about-the-app-dashboard).\n * @maxLength 100\n */\n providerName?: string;\n}\n\n/** Base URI configuration for a service plugin. Wix uses these URIs to call your service plugin methods. */\nexport interface SpiBaseUri {\n /**\n * Base URI for your service plugin. Wix appends each method's path to this URI.\n *\n * For example, to receive requests at `https://my-app.com/v1/my-method`, set this field to `https://my-app.com/`.\n * @minLength 6\n * @maxLength 2048\n */\n baseUri?: string;\n /** Alternative URIs for specific methods. Use these to override the default URI for individual methods. */\n alternativeUris?: AlternativeUri[];\n}\n\n/** Custom URI for the specified service plugin method. */\nexport interface AlternativeUri {\n /**\n * Name of the method to call at the absolute URI, in PascalCase. For example, to call [Get Shipping Rates](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates) on an alternative URI, specify `GetShippingRates`.\n * @minLength 3\n * @maxLength 128\n */\n methodName?: string;\n /**\n * Absolute URI that Wix calls for this method. Wix doesn't append any path to this URI.\n *\n * The URI must begin with `https://`, such as `https://my-app.com/v1/my-custom-method`.\n * @minLength 6\n * @maxLength 2048\n */\n absoluteUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n requestId?: string | null;\n /**\n * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n * @format CURRENCY\n */\n currency?: string | null;\n /** An object that describes the identity that triggered this request. */\n identity?: IdentificationData;\n /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n languages?: string[];\n /**\n * The service provider app's instance ID.\n * @format GUID\n */\n instanceId?: string | null;\n}\n\nexport enum IdentityType {\n UNKNOWN = 'UNKNOWN',\n ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n MEMBER = 'MEMBER',\n WIX_USER = 'WIX_USER',\n APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n /** @readonly */\n identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n}\n","import { ServicePluginDefinition } from '@wix/sdk-types';\nimport {\n Context,\n CheckSubscriberPermissionsRequest,\n CheckSubscriberPermissionsResponse,\n} from './service-plugins-types.js';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\n\nexport interface CheckSubscriberPermissionsEnvelope {\n request: CheckSubscriberPermissionsRequest;\n metadata: Context;\n}\n\nexport const provideHandlers = ServicePluginDefinition<{\n /**\n *\n * Checks whether a subscriber has permission to receive messages on a Wix Realtime channel.\n *\n * Wix calls this method when a subscriber from another app attempts a [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions) to one of your app's channels. The call is synchronous: Wix waits for your response before allowing or denying the subscription.\n *\n * To allow the subscriber to receive messages on the specified channel or resource, return `{ read: true }`. To deny, return `{ read: false }`.\n *\n * Learn more about [the Realtime APIs](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction).\n *\n * Error handling:\n * - Don't throw an error for normal denials. Use `{ read: false }` instead.\n * - If your service throws an error, times out, or is unreachable, Wix denies the subscription with a 503 HTTP status code.\n * - Return `InvalidArgumentError` only when the request contains invalid or missing data that prevents your service from processing it. */\n checkSubscriberPermissions(\n payload: CheckSubscriberPermissionsEnvelope\n ):\n | CheckSubscriberPermissionsResponse\n | Promise<CheckSubscriberPermissionsResponse>;\n}>('REALTIME_PERMISSIONS_PROVIDER', [\n {\n name: 'checkSubscriberPermissions',\n primaryHttpMappingPath: '/v1/check-subscriber-permissions',\n transformations: {\n toREST: (payload: any) => {\n const toRestResponse = payload;\n\n return renameKeysFromSDKRequestToRESTRequest(toRestResponse);\n },\n fromREST: (payload: any) => {\n const fromRestRequest = payload;\n\n return renameKeysFromRESTResponseToSDKResponse(fromRestRequest);\n },\n },\n },\n]);\n","import './interfaces-realtime-v1-realtime-permissions-provider.public.js';\nimport { createServicePluginModule } from '@wix/sdk-runtime/service-plugin-modules';\nimport { BuildServicePluginDefinition } from '@wix/sdk-types';\nimport { provideHandlers as publicProvideHandlers } from './interfaces-realtime-v1-realtime-permissions-provider.public.js';\n\nexport { publicProvideHandlers };\n\nexport const provideHandlers: BuildServicePluginDefinition<\n typeof publicProvideHandlers\n> &\n typeof publicProvideHandlers = createServicePluginModule(\n publicProvideHandlers\n);\n","export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n"],"mappings":";AA4CO,IAAK,iBAAL,kBAAKA,oBAAL;AAEL,EAAAA,gBAAA,iCAA8B;AAE9B,EAAAA,gBAAA,WAAQ;AAER,EAAAA,gBAAA,YAAS;AAET,EAAAA,gBAAA,aAAU;AARA,SAAAA;AAAA,GAAA;AA4FL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;;;ACxIZ,SAAS,+BAA+B;AAMxC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOA,IAAM,kBAAkB,wBAoB5B,iCAAiC;AAAA,EAClC;AAAA,IACE,MAAM;AAAA,IACN,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,MACf,QAAQ,CAAC,YAAiB;AACxB,cAAM,iBAAiB;AAEvB,eAAO,sCAAsC,cAAc;AAAA,MAC7D;AAAA,MACA,UAAU,CAAC,YAAiB;AAC1B,cAAM,kBAAkB;AAExB,eAAO,wCAAwC,eAAe;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ACpDD,SAAS,iCAAiC;AAMnC,IAAMC,mBAGoB;AAAA,EAC/B;AACF;;;ACZO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAcjD,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,EACF;AAIF;AAAA;AA9Ba,wBA6BK,SAAS;","names":["SubscriberType","IdentityType","provideHandlers"]}
|
|
@@ -1,46 +1,20 @@
|
|
|
1
|
-
import { i as CheckSubscriberPermissionsEnvelope, c as CheckSubscriberPermissionsResponse } from './service-plugins-error-classes-
|
|
2
|
-
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-
|
|
1
|
+
import { i as CheckSubscriberPermissionsEnvelope, c as CheckSubscriberPermissionsResponse } from './service-plugins-error-classes-B7a57gue.mjs';
|
|
2
|
+
export { A as AlternativeUri, a as Channel, C as CheckSubscriberPermissionsRequest, e as Context, f as IdentificationData, g as IdentificationDataIdOneOf, I as IdentityType, h as InvalidArgumentWixError, R as RealtimePermissionsProviderConfig, d as SpiBaseUri, S as Subscriber, b as SubscriberType } from './service-plugins-error-classes-B7a57gue.mjs';
|
|
3
3
|
import '@wix/sdk-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Checks whether a subscriber has permission to receive messages on a Wix Realtime channel.
|
|
7
7
|
*
|
|
8
|
-
* Wix calls this method when
|
|
9
|
-
* (for example, when `wix-duplexer-sockets-server` resolves access for a client).
|
|
10
|
-
* The call is **synchronous**: Wix waits for your response before allowing or denying
|
|
11
|
-
* receive / send capabilities for that subscription attempt.
|
|
8
|
+
* Wix calls this method when a subscriber from another app attempts a [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions) to one of your app's channels. The call is synchronous: Wix waits for your response before allowing or denying the subscription.
|
|
12
9
|
*
|
|
13
|
-
*
|
|
14
|
-
* *receive channel messages** and **publish client events**, respectively.
|
|
15
|
-
* Normal **authorization denials** should be expressed with `read` / `write`
|
|
16
|
-
* set to `false`, not by throwing.
|
|
10
|
+
* To allow the subscriber to receive messages on the specified channel or resource, return `{ read: true }`. To deny, return `{ read: false }`.
|
|
17
11
|
*
|
|
18
|
-
*
|
|
19
|
-
* has selected your app as the implementer, the **Realtime Permissions host** reports
|
|
20
|
-
* *gRPC `UNAVAILABLE` / HTTP 503** to its caller. It does **not** return a
|
|
21
|
-
* structured “reason” field for that failure mode. Keep handlers fast and avoid
|
|
22
|
-
* blocking calls where possible.
|
|
12
|
+
* Learn more about [the Realtime APIs](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction).
|
|
23
13
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* *Your implementation should:**
|
|
29
|
-
* - Use `channel`, `subscriber`, and `requesting_app_id` (see field comments) to enforce your rules.
|
|
30
|
-
* - Return `read` / `write` explicitly for every successful decision.
|
|
31
|
-
*
|
|
32
|
-
* *Error handling:** Return **`InvalidArgumentError`** only when the **request payload**
|
|
33
|
-
* is invalid for your implementation (for example, a channel or subscriber shape you
|
|
34
|
-
* cannot interpret). Do **not** use that error for normal policy denials.
|
|
35
|
-
*
|
|
36
|
-
* Parameter: `CheckSubscriberPermissionsRequest`.
|
|
37
|
-
* Response: `CheckSubscriberPermissionsResponse` — for example:
|
|
38
|
-
* ```json
|
|
39
|
-
* {
|
|
40
|
-
* "read": true,
|
|
41
|
-
* "write": false
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
14
|
+
* Error handling:
|
|
15
|
+
* - Don't throw an error for normal denials. Use `{ read: false }` instead.
|
|
16
|
+
* - If your service throws an error, times out, or is unreachable, Wix denies the subscription with a 503 HTTP status code.
|
|
17
|
+
* - Return `InvalidArgumentError` only when the request contains invalid or missing data that prevents your service from processing it.
|
|
44
18
|
* @throws InvalidArgumentWixError
|
|
45
19
|
*/
|
|
46
20
|
declare function checkSubscriberPermissions(payload: CheckSubscriberPermissionsEnvelope): CheckSubscriberPermissionsResponse | Promise<CheckSubscriberPermissionsResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/service-plugins-error-classes.ts","../../src/service-plugins-types.ts"],"sourcesContent":["export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n","/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /**
|
|
1
|
+
{"version":3,"sources":["../../src/service-plugins-error-classes.ts","../../src/service-plugins-types.ts"],"sourcesContent":["export class InvalidArgumentWixError extends Error {\n /** @hidden */\n httpCode: number;\n /** @hidden */\n statusCode: string;\n /** @hidden */\n applicationCode: string;\n /** @hidden */\n name: string;\n /** @hidden */\n errorType: string;\n /** @hidden */\n spiErrorData: object;\n\n constructor() {\n super('InvalidArgumentError');\n\n this.httpCode = 400;\n this.statusCode = 'INVALID_ARGUMENT';\n this.applicationCode = 'INVALID_ARGUMENT';\n this.name = 'InvalidArgumentError';\n this.errorType = 'SPI';\n this.spiErrorData = {\n name: 'InvalidArgumentError',\n applicationCode: 'INVALID_ARGUMENT',\n };\n }\n\n /** @hidden */\n static readonly __type = 'wix_spi_error';\n}\n","/** Request to check subscriber permissions for a realtime channel. */\nexport interface CheckSubscriberPermissionsRequest {\n /** [Channel or resource](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#channels-and-channel-resources) that the subscriber is attempting to join. */\n channel?: Channel;\n /** [Subscriber](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/subscriber/introduction) attempting the subscription. */\n subscriber?: Subscriber;\n /**\n * ID of the app attempting the [cross-app subscription](https://dev.wix.com/docs/sdk/core-modules/realtime/realtime/introduction#cross-app-subscriptions). When empty, the app context is unavailable.\n * @format GUID\n */\n requestingAppId?: string | null;\n}\n\n/** Realtime broadcast channel. Publishers send messages to channels and subscribers listen to them. */\nexport interface Channel {\n /**\n * Channel name. Supports only alphanumeric characters, hyphens, and underscores.\n * @maxLength 140\n */\n name?: string;\n /**\n * Resource ID. Resources are independent sub-channels within a channel.\n * A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** Subscriber to a channel or resource. */\nexport interface Subscriber {\n /**\n * Subscriber ID.\n * @maxLength 1000\n */\n _id?: string;\n /**\n * Subscriber identity type.\n *\n * Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities).\n */\n type?: SubscriberType;\n}\n\n/** Subscriber identity type. Learn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities). */\nexport enum SubscriberType {\n /** Unknown subscriber type. */\n SUBSCRIBER_TYPE_UNSPECIFIED = 'SUBSCRIBER_TYPE_UNSPECIFIED',\n /** [Wix user](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#wix-user). */\n ADMIN = 'ADMIN',\n /** Logged-in [site member](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#member). */\n MEMBER = 'MEMBER',\n /** [Site visitor](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities#visitor). */\n VISITOR = 'VISITOR',\n}\n\n/** Response containing the subscriber's permissions for the channel. */\nexport interface CheckSubscriberPermissionsResponse {\n /** Whether the subscriber may receive messages on the channel. */\n read?: boolean;\n}\n\n/** Configuration for the Realtime Permissions Provider service plugin. */\nexport interface RealtimePermissionsProviderConfig {\n /** URI configuration for this service plugin. Wix calls your service plugin methods at these URIs. */\n deploymentUri?: SpiBaseUri;\n /**\n * Display name for this permissions provider in the [app dashboard](https://dev.wix.com/docs/build-apps/develop-your-app/app-workspace/about-the-app-dashboard).\n * @maxLength 100\n */\n providerName?: string;\n}\n\n/** Base URI configuration for a service plugin. Wix uses these URIs to call your service plugin methods. */\nexport interface SpiBaseUri {\n /**\n * Base URI for your service plugin. Wix appends each method's path to this URI.\n *\n * For example, to receive requests at `https://my-app.com/v1/my-method`, set this field to `https://my-app.com/`.\n * @minLength 6\n * @maxLength 2048\n */\n baseUri?: string;\n /** Alternative URIs for specific methods. Use these to override the default URI for individual methods. */\n alternativeUris?: AlternativeUri[];\n}\n\n/** Custom URI for the specified service plugin method. */\nexport interface AlternativeUri {\n /**\n * Name of the method to call at the absolute URI, in PascalCase. For example, to call [Get Shipping Rates](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates) on an alternative URI, specify `GetShippingRates`.\n * @minLength 3\n * @maxLength 128\n */\n methodName?: string;\n /**\n * Absolute URI that Wix calls for this method. Wix doesn't append any path to this URI.\n *\n * The URI must begin with `https://`, such as `https://my-app.com/v1/my-custom-method`.\n * @minLength 6\n * @maxLength 2048\n */\n absoluteUri?: string;\n}\n\n/**\n * this message is not directly used by any service,\n * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform.\n * e.g. SPIs, event-handlers, etc..\n * NOTE: this context object MUST be provided as the last argument in each Velo method signature.\n *\n * Example:\n * ```typescript\n * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) {\n * ...\n * }\n * ```\n */\nexport interface Context {\n /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */\n requestId?: string | null;\n /**\n * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.\n * @format CURRENCY\n */\n currency?: string | null;\n /** An object that describes the identity that triggered this request. */\n identity?: IdentificationData;\n /** A string representing a language and region in the format of `\"xx-XX\"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash \"-\", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `\"en-US\"`. */\n languages?: string[];\n /**\n * The service provider app's instance ID.\n * @format GUID\n */\n instanceId?: string | null;\n}\n\nexport enum IdentityType {\n UNKNOWN = 'UNKNOWN',\n ANONYMOUS_VISITOR = 'ANONYMOUS_VISITOR',\n MEMBER = 'MEMBER',\n WIX_USER = 'WIX_USER',\n APP = 'APP',\n}\n\nexport interface IdentificationData extends IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n /** @readonly */\n identityType?: IdentityType;\n}\n\n/** @oneof */\nexport interface IdentificationDataIdOneOf {\n /**\n * ID of a site visitor that has not logged in to the site.\n * @format GUID\n */\n anonymousVisitorId?: string;\n /**\n * ID of a site visitor that has logged in to the site.\n * @format GUID\n */\n memberId?: string;\n /**\n * ID of a Wix user (site owner, contributor, etc.).\n * @format GUID\n */\n wixUserId?: string;\n /**\n * ID of an app.\n * @format GUID\n */\n appId?: string;\n}\n"],"mappings":";AAAO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAcjD,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,eAAe;AAAA,MAClB,MAAM;AAAA,MACN,iBAAiB;AAAA,IACnB;AAAA,EACF;AAIF;AAAA;AA9Ba,wBA6BK,SAAS;;;ACepB,IAAK,iBAAL,kBAAKA,oBAAL;AAEL,EAAAA,gBAAA,iCAA8B;AAE9B,EAAAA,gBAAA,WAAQ;AAER,EAAAA,gBAAA,YAAS;AAET,EAAAA,gBAAA,aAAU;AARA,SAAAA;AAAA,GAAA;AA4FL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,uBAAoB;AACpB,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,SAAM;AALI,SAAAA;AAAA,GAAA;","names":["SubscriberType","IdentityType"]}
|