Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/api-graphql

Package Overview
Dependencies
Maintainers
8
Versions
1710
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/api-graphql - npm Package Compare versions

Comparing version 4.4.4-unstable.5d549c3.0 to 4.4.4-unstable.e0fdeb7.0

11

dist/cjs/Providers/AWSAppSyncEventsProvider/index.js
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppSyncEventProvider = void 0;
exports.AppSyncEventProvider = exports.AWSAppSyncEventProvider = void 0;
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

@@ -96,4 +96,13 @@ // SPDX-License-Identifier: Apache-2.0

}
_extractConnectionTimeout(data) {
const { connectionTimeoutMs = constants_1.DEFAULT_KEEP_ALIVE_TIMEOUT } = data;
return connectionTimeoutMs;
}
_extractErrorCodeAndType(data) {
const { errors: [{ errorType = '', errorCode = 0 } = {}] = [] } = data;
return { errorCode, errorType };
}
}
exports.AWSAppSyncEventProvider = AWSAppSyncEventProvider;
exports.AppSyncEventProvider = new AWSAppSyncEventProvider();
//# sourceMappingURL=index.js.map

@@ -81,4 +81,12 @@ 'use strict';

}
_extractConnectionTimeout(data) {
const { payload: { connectionTimeoutMs = constants_1.DEFAULT_KEEP_ALIVE_TIMEOUT } = {}, } = data;
return connectionTimeoutMs;
}
_extractErrorCodeAndType(data) {
const { payload: { errors: [{ errorType = '', errorCode = 0 } = {}] = [] } = {}, } = data;
return { errorCode, errorType };
}
}
exports.AWSAppSyncRealTimeProvider = AWSAppSyncRealTimeProvider;
//# sourceMappingURL=index.js.map

5

dist/cjs/Providers/AWSWebSocketProvider/appsyncUrl.js

@@ -10,3 +10,3 @@ 'use strict';

const standardDomainPattern = /^https:\/\/\w{26}\.appsync-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/graphql$/i;
const eventDomainPattern = /^https:\/\/\w{26}\.ddpg-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/event$/i;
const eventDomainPattern = /^https:\/\/\w{26}\.\w+-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/event$/i;
const customDomainPath = '/realtime';

@@ -23,3 +23,4 @@ const isCustomDomain = (url) => {

.concat(customDomainPath)
.replace('ddpg-api', 'grt-gamma');
.replace('ddpg-api', 'grt-gamma')
.replace('appsync-api', 'appsync-realtime-api');
}

@@ -26,0 +27,0 @@ else if ((0, exports.isCustomDomain)(realtimeEndpoint)) {

@@ -42,3 +42,6 @@ 'use strict';

const { errorType, errorCode } = err;
if (constants_1.NON_RETRYABLE_CODES.includes(errorCode)) {
if (constants_1.NON_RETRYABLE_CODES.includes(errorCode) ||
// Event API does not currently return `errorCode`. This may change in the future.
// For now fall back to also checking known non-retryable error types
constants_1.NON_RETRYABLE_ERROR_TYPES.includes(errorType)) {
throw new utils_1.NonRetryableError(errorType);

@@ -437,7 +440,7 @@ }

});
this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`);
this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload ?? data)}`);
observer.error({
errors: [
{
...new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`),
...new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload ?? data)}`),
},

@@ -579,3 +582,4 @@ ],

const data = JSON.parse(message.data);
const { type, payload: { connectionTimeoutMs = constants_1.DEFAULT_KEEP_ALIVE_TIMEOUT } = {}, } = data;
const { type } = data;
const connectionTimeoutMs = this._extractConnectionTimeout(data);
if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_ACK) {

@@ -588,3 +592,3 @@ ackOk = true;

if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
const { payload: { errors: [{ errorType = '', errorCode = 0 } = {}] = [], } = {}, } = data;
const { errorType, errorCode } = this._extractErrorCodeAndType(data);
// TODO(Eslint): refactor to reject an Error object instead of a plain object

@@ -591,0 +595,0 @@ // eslint-disable-next-line prefer-promise-reject-errors

'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.RECONNECT_INTERVAL = exports.RECONNECT_DELAY = exports.DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = exports.DEFAULT_KEEP_ALIVE_TIMEOUT = exports.START_ACK_TIMEOUT = exports.CONNECTION_INIT_TIMEOUT = exports.AWS_APPSYNC_REALTIME_HEADERS = exports.SOCKET_STATUS = exports.SUBSCRIPTION_STATUS = exports.MESSAGE_TYPES = exports.CONNECTION_STATE_CHANGE = exports.NON_RETRYABLE_CODES = exports.MAX_DELAY_MS = exports.AMPLIFY_SYMBOL = void 0;
exports.RECONNECT_INTERVAL = exports.RECONNECT_DELAY = exports.DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = exports.DEFAULT_KEEP_ALIVE_TIMEOUT = exports.START_ACK_TIMEOUT = exports.CONNECTION_INIT_TIMEOUT = exports.AWS_APPSYNC_REALTIME_HEADERS = exports.SOCKET_STATUS = exports.SUBSCRIPTION_STATUS = exports.MESSAGE_TYPES = exports.CONNECTION_STATE_CHANGE = exports.NON_RETRYABLE_ERROR_TYPES = exports.NON_RETRYABLE_CODES = exports.MAX_DELAY_MS = exports.AMPLIFY_SYMBOL = void 0;
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

@@ -11,2 +11,6 @@ // SPDX-License-Identifier: Apache-2.0

exports.NON_RETRYABLE_CODES = [400, 401, 403];
exports.NON_RETRYABLE_ERROR_TYPES = [
'BadRequestException',
'UnauthorizedException',
];
exports.CONNECTION_STATE_CHANGE = 'ConnectionStateChange';

@@ -13,0 +17,0 @@ (function (MESSAGE_TYPES) {

@@ -22,3 +22,3 @@ import { CustomUserAgentDetails, DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';

}
declare class AWSAppSyncEventProvider extends AWSWebSocketProvider {
export declare class AWSAppSyncEventProvider extends AWSWebSocketProvider {
constructor();

@@ -42,4 +42,9 @@ getProviderName(): string;

};
protected _extractConnectionTimeout(data: Record<string, any>): number;
protected _extractErrorCodeAndType(data: Record<string, any>): {
errorCode: number;
errorType: string;
};
}
export declare const AppSyncEventProvider: AWSAppSyncEventProvider;
export {};

@@ -41,3 +41,8 @@ import { CustomUserAgentDetails, DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';

};
protected _extractConnectionTimeout(data: Record<string, any>): number;
protected _extractErrorCodeAndType(data: any): {
errorCode: number;
errorType: string;
};
}
export {};

@@ -72,2 +72,7 @@ import { Observable } from 'rxjs';

];
protected abstract _extractConnectionTimeout(data: Record<string, any>): number;
protected abstract _extractErrorCodeAndType(data: Record<string, any>): {
errorCode: number;
errorType: string;
};
private _handleIncomingSubscriptionMessage;

@@ -74,0 +79,0 @@ private _errorDisconnect;

export { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';
export declare const MAX_DELAY_MS = 5000;
export declare const NON_RETRYABLE_CODES: number[];
export declare const NON_RETRYABLE_ERROR_TYPES: string[];
export declare const CONNECTION_STATE_CHANGE = "ConnectionStateChange";

@@ -5,0 +6,0 @@ export declare enum MESSAGE_TYPES {

{
"name": "@aws-amplify/api-graphql",
"version": "4.4.4-unstable.5d549c3.0+5d549c3",
"version": "4.4.4-unstable.e0fdeb7.0+e0fdeb7",
"description": "Api-graphql category of aws-amplify",

@@ -87,4 +87,4 @@ "main": "./dist/cjs/index.js",

"dependencies": {
"@aws-amplify/api-rest": "4.0.55-unstable.5d549c3.0+5d549c3",
"@aws-amplify/core": "6.4.8-unstable.5d549c3.0+5d549c3",
"@aws-amplify/api-rest": "4.0.55-unstable.e0fdeb7.0+e0fdeb7",
"@aws-amplify/core": "6.4.8-unstable.e0fdeb7.0+e0fdeb7",
"@aws-amplify/data-schema": "^1.7.0",

@@ -105,3 +105,3 @@ "@aws-sdk/types": "3.387.0",

],
"gitHead": "5d549c36cd4fd42c7a9bdb400f5f797046ea0039"
"gitHead": "e0fdeb7bcbb24822607267b08b2919af5e73f2db"
}

@@ -12,3 +12,3 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

import { MESSAGE_TYPES } from '../constants';
import { DEFAULT_KEEP_ALIVE_TIMEOUT, MESSAGE_TYPES } from '../constants';
import { AWSWebSocketProvider } from '../AWSWebSocketProvider';

@@ -48,3 +48,3 @@ import { awsRealTimeHeaderBasedAuth } from '../AWSWebSocketProvider/authHeaders';

class AWSAppSyncEventProvider extends AWSWebSocketProvider {
export class AWSAppSyncEventProvider extends AWSWebSocketProvider {
constructor() {

@@ -192,4 +192,19 @@ super({ providerName: PROVIDER_NAME, wsProtocolName: WS_PROTOCOL_NAME });

}
protected _extractConnectionTimeout(data: Record<string, any>): number {
const { connectionTimeoutMs = DEFAULT_KEEP_ALIVE_TIMEOUT } = data;
return connectionTimeoutMs;
}
protected _extractErrorCodeAndType(data: Record<string, any>): {
errorCode: number;
errorType: string;
} {
const { errors: [{ errorType = '', errorCode = 0 } = {}] = [] } = data;
return { errorCode, errorType };
}
}
export const AppSyncEventProvider = new AWSAppSyncEventProvider();

@@ -13,3 +13,3 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

import { MESSAGE_TYPES } from '../constants';
import { DEFAULT_KEEP_ALIVE_TIMEOUT, MESSAGE_TYPES } from '../constants';
import { AWSWebSocketProvider } from '../AWSWebSocketProvider';

@@ -162,2 +162,21 @@ import { awsRealTimeHeaderBasedAuth } from '../AWSWebSocketProvider/authHeaders';

}
protected _extractConnectionTimeout(data: Record<string, any>): number {
const {
payload: { connectionTimeoutMs = DEFAULT_KEEP_ALIVE_TIMEOUT } = {},
} = data;
return connectionTimeoutMs;
}
protected _extractErrorCodeAndType(data: any): {
errorCode: number;
errorType: string;
} {
const {
payload: { errors: [{ errorType = '', errorCode = 0 } = {}] = [] } = {},
} = data;
return { errorCode, errorType };
}
}

@@ -16,3 +16,3 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

const eventDomainPattern =
/^https:\/\/\w{26}\.ddpg-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/event$/i;
/^https:\/\/\w{26}\.\w+-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/event$/i;
const customDomainPath = '/realtime';

@@ -35,3 +35,4 @@

.concat(customDomainPath)
.replace('ddpg-api', 'grt-gamma');
.replace('ddpg-api', 'grt-gamma')
.replace('appsync-api', 'appsync-realtime-api');
} else if (isCustomDomain(realtimeEndpoint)) {

@@ -38,0 +39,0 @@ realtimeEndpoint = realtimeEndpoint.concat(customDomainPath);

@@ -30,2 +30,3 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

NON_RETRYABLE_CODES,
NON_RETRYABLE_ERROR_TYPES,
SOCKET_STATUS,

@@ -550,2 +551,11 @@ START_ACK_TIMEOUT,

protected abstract _extractConnectionTimeout(
data: Record<string, any>,
): number;
protected abstract _extractErrorCodeAndType(data: Record<string, any>): {
errorCode: number;
errorType: string;
};
private _handleIncomingSubscriptionMessage(message: MessageEvent) {

@@ -634,3 +644,3 @@ if (typeof message.data !== 'string') {

this.logger.debug(
`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`,
`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload ?? data)}`,
);

@@ -642,3 +652,3 @@

...new GraphQLError(
`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`,
`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload ?? data)}`,
),

@@ -837,7 +847,7 @@ },

const data = JSON.parse(message.data) as ParsedMessagePayload;
const {
type,
payload: { connectionTimeoutMs = DEFAULT_KEEP_ALIVE_TIMEOUT } = {},
} = data;
const { type } = data;
const connectionTimeoutMs = this._extractConnectionTimeout(data);
if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {

@@ -852,7 +862,3 @@ ackOk = true;

if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
const {
payload: {
errors: [{ errorType = '', errorCode = 0 } = {}] = [],
} = {},
} = data;
const { errorType, errorCode } = this._extractErrorCodeAndType(data);

@@ -929,3 +935,8 @@ // TODO(Eslint): refactor to reject an Error object instead of a plain object

if (NON_RETRYABLE_CODES.includes(errorCode)) {
if (
NON_RETRYABLE_CODES.includes(errorCode) ||
// Event API does not currently return `errorCode`. This may change in the future.
// For now fall back to also checking known non-retryable error types
NON_RETRYABLE_ERROR_TYPES.includes(errorType)
) {
throw new NonRetryableError(errorType);

@@ -932,0 +943,0 @@ } else if (errorType) {

@@ -8,2 +8,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

export const NON_RETRYABLE_CODES = [400, 401, 403];
export const NON_RETRYABLE_ERROR_TYPES = [
'BadRequestException',
'UnauthorizedException',
];

@@ -10,0 +14,0 @@ export const CONNECTION_STATE_CHANGE = 'ConnectionStateChange';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc