CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-aws-sdk--client-sns

AWS SDK for JavaScript SNS Client for Node.js, Browser and React Native

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

AWS SDK Client SNS

AWS SDK for JavaScript SNS Client provides a comprehensive TypeScript library for Amazon Simple Notification Service (SNS). It enables developers to build distributed web applications with real-time push notification capabilities across multiple delivery protocols including email, SMS, HTTP/HTTPS endpoints, and mobile push notifications.

Package Information

  • Package Name: @aws-sdk/client-sns
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @aws-sdk/client-sns

Core Imports

import { SNSClient, CreateTopicCommand, PublishCommand } from "@aws-sdk/client-sns";

For aggregated client with all methods:

import { SNS } from "@aws-sdk/client-sns";

CommonJS:

const { SNSClient, CreateTopicCommand, PublishCommand } = require("@aws-sdk/client-sns");

Basic Usage

import { SNSClient, CreateTopicCommand, PublishCommand } from "@aws-sdk/client-sns";

// Create client
const client = new SNSClient({ region: "us-east-1" });

// Create a topic
const createTopicResult = await client.send(new CreateTopicCommand({
  Name: "MyTopic"
}));

// Publish a message
const publishResult = await client.send(new PublishCommand({
  TopicArn: createTopicResult.TopicArn,
  Message: "Hello from SNS!",
  Subject: "Test Message"
}));

Architecture

The AWS SNS client follows a command-based architecture with these key components:

  • SNSClient: Main service client that sends commands to SNS
  • Commands: Individual operation classes (42 commands) for each SNS API action
  • Models: TypeScript interfaces for all input/output data structures
  • Pagination: Utilities for handling paginated list operations
  • Exceptions: Strongly-typed error classes for comprehensive error handling

Capabilities

Client Configuration

Core client setup and configuration options for AWS SNS service access.

class SNSClient {
  constructor(configuration: SNSClientConfig);
  send<InputType, OutputType>(
    command: Command<InputType, OutputType, SNSClientResolvedConfig>
  ): Promise<OutputType>;
  destroy(): void;
}

interface SNSClientConfig {
  region?: string | Provider<string>;
  credentials?: AwsCredentialIdentityProvider;
  maxAttempts?: number | Provider<number>;
  retryMode?: string | Provider<string>;
  requestHandler?: RequestHandler<any, any>;
  logger?: Logger;
  useDualstackEndpoint?: boolean | Provider<boolean>;
  useFipsEndpoint?: boolean | Provider<boolean>;
}

Client Configuration

Topic Management

Create, delete, and manage SNS topics with comprehensive attribute control and listing capabilities.

class CreateTopicCommand {
  constructor(input: CreateTopicInput);
}

interface CreateTopicInput {
  Name: string | undefined;
  Attributes?: Record<string, string> | undefined;
  Tags?: Tag[] | undefined;
  DataProtectionPolicy?: string | undefined;
}

interface CreateTopicResponse {
  TopicArn?: string;
}

Topic Management

Message Publishing

Publish messages to topics and endpoints with support for message attributes, batch operations, and various delivery protocols.

class PublishCommand {
  constructor(input: PublishInput);
}

interface PublishInput {
  TopicArn?: string | undefined;
  TargetArn?: string | undefined;
  PhoneNumber?: string | undefined;
  Message: string | undefined;
  Subject?: string | undefined;
  MessageStructure?: string | undefined;
  MessageAttributes?: Record<string, MessageAttributeValue> | undefined;
  MessageGroupId?: string | undefined;
  MessageDeduplicationId?: string | undefined;
}

interface PublishResponse {
  MessageId?: string;
  SequenceNumber?: string;
}

Message Publishing

Subscription Management

Subscribe endpoints to topics, manage subscription attributes, and handle subscription confirmation workflows.

class SubscribeCommand {
  constructor(input: SubscribeInput);
}

interface SubscribeInput {
  TopicArn: string;
  Protocol: string;
  Endpoint?: string;
  Attributes?: SubscriptionAttributesMap;
  ReturnSubscriptionArn?: boolean;
}

interface SubscribeResponse {
  SubscriptionArn?: string;
}

Subscription Management

Platform Applications and Endpoints

Manage mobile push notification platform applications and device endpoints for iOS, Android, and other platforms.

class CreatePlatformApplicationCommand {
  constructor(input: CreatePlatformApplicationInput);
}

interface CreatePlatformApplicationInput {
  Name: string;
  Platform: string;
  Attributes: PlatformApplicationAttributesMap;
}

interface CreatePlatformApplicationResponse {
  PlatformApplicationArn?: string;
}

Platform Applications and Endpoints

SMS Management

Comprehensive SMS functionality including attributes configuration, phone number opt-out management, and sandbox environment support.

class SetSMSAttributesCommand {
  constructor(input: SetSMSAttributesInput);
}

interface SetSMSAttributesInput {
  attributes: SMSAttributesMap;
}

interface SMSAttributesMap {
  [key: string]: string;
}

SMS Management

Permission Management

Add and remove permissions for SNS topics to control access across AWS accounts and services.

class AddPermissionCommand {
  constructor(input: AddPermissionInput);
}

interface AddPermissionInput {
  TopicArn: string;
  Label: string;
  AWSAccountId: string[];
  ActionName: string[];
}

Permission Management

Resource Tagging

Tag SNS resources for organization, cost allocation, and access control with comprehensive tag management capabilities.

class TagResourceCommand {
  constructor(input: TagResourceRequest);
}

interface TagResourceRequest {
  ResourceArn: string;
  Tags: Tag[];
}

interface Tag {
  Key: string;
  Value: string;
}

Resource Tagging

Data Protection

Configure data protection policies for SNS topics to control data handling and privacy compliance.

class PutDataProtectionPolicyCommand {
  constructor(input: PutDataProtectionPolicyInput);
}

interface PutDataProtectionPolicyInput {
  ResourceArn: string;
  DataProtectionPolicy: string;
}

Data Protection

List Operations and Pagination

Paginated listing operations for topics, subscriptions, platform applications, and other SNS resources.

function paginateListTopics(
  config: SNSPaginationConfiguration,
  input: ListTopicsInput
): Paginator<ListTopicsCommandOutput>;

interface SNSPaginationConfiguration extends PaginationConfiguration {
  client: SNSClient;
}

List Operations and Pagination

Types

Core Data Models

interface Topic {
  TopicArn?: string;
}

interface Subscription {
  SubscriptionArn?: string;
  Owner?: string;
  Protocol?: string;
  Endpoint?: string;
  TopicArn?: string;
}

interface Endpoint {
  EndpointArn?: string;
  Attributes?: EndpointAttributesMap;
}

interface MessageAttributeValue {
  DataType: string;
  StringValue?: string;
  BinaryValue?: Uint8Array;
  StringListValues?: string[];
  BinaryListValues?: Uint8Array[];
}

interface PlatformApplication {
  PlatformApplicationArn?: string;
  Attributes?: PlatformApplicationAttributesMap;
}

Exception Types

The SNS client provides comprehensive error handling with strongly-typed exceptions for different error scenarios:

class SNSServiceException extends Error {
  name: string;
  $fault: 'client' | 'server';
  $metadata: ResponseMetadata;
}

class AuthorizationErrorException extends SNSServiceException {
  name: 'AuthorizationErrorException';
  $fault: 'client';
}

class InvalidParameterException extends SNSServiceException {
  name: 'InvalidParameterException';
  $fault: 'client';
}

class InternalErrorException extends SNSServiceException {
  name: 'InternalErrorException';
  $fault: 'server';
}

class NotFoundException extends SNSServiceException {
  name: 'NotFoundException';
  $fault: 'client';
}

class ThrottledException extends SNSServiceException {
  name: 'ThrottledException';
  $fault: 'server';
}

Enumerations

enum LanguageCodeString {
  de_DE = 'de-DE',
  en_GB = 'en-GB',
  en_US = 'en-US',
  es_419 = 'es-419',
  es_ES = 'es-ES',
  fr_CA = 'fr-CA',
  fr_FR = 'fr-FR',
  it_IT = 'it-IT',
  jp_JP = 'ja-JP',
  kr_KR = 'kr-KR',
  pt_BR = 'pt-BR',
  zh_CN = 'zh-CN',
  zh_TW = 'zh-TW'
}

enum NumberCapability {
  MMS = 'MMS',
  SMS = 'SMS',
  VOICE = 'VOICE'
}

enum RouteType {
  Premium = 'Premium',
  Promotional = 'Promotional',
  Transactional = 'Transactional'
}

enum SMSSandboxPhoneNumberVerificationStatus {
  Pending = 'Pending',
  Verified = 'Verified'
}
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@aws-sdk/client-sns@3.879.x
Publish Source
CLI
Badge
tessl/npm-aws-sdk--client-sns badge