@aws-amplify/datastore 5.0.1-console-preview.11cf989.0 → 5.0.1-console-preview.4ae78ed.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -118,10 +118,10 @@ function getAuthRules(_a) {
118
118
  // We shouldn't attempt User Pool or OIDC if there isn't an authenticated user
119
119
  if (currentUser) {
120
120
  if (rule.provider === types_1.ModelAttributeAuthProvider.USER_POOLS) {
121
- authModes.add('jwt');
121
+ authModes.add('userPool');
122
122
  }
123
123
  else if (rule.provider === types_1.ModelAttributeAuthProvider.OIDC) {
124
- authModes.add('jwt');
124
+ authModes.add('oidc');
125
125
  }
126
126
  }
127
127
  break;
@@ -132,7 +132,7 @@ function getAuthRules(_a) {
132
132
  // private with no provider means userPools
133
133
  if (!rule.provider ||
134
134
  rule.provider === types_1.ModelAttributeAuthProvider.USER_POOLS) {
135
- authModes.add('jwt');
135
+ authModes.add('userPool');
136
136
  }
137
137
  else if (rule.provider === types_1.ModelAttributeAuthProvider.IAM) {
138
138
  authModes.add('iam');
@@ -2055,16 +2055,12 @@ var DataStore = /** @class */ (function () {
2055
2055
  if (config === void 0) { config = {}; }
2056
2056
  _this.amplifyContext.InternalAPI = _this.InternalAPI;
2057
2057
  var configDataStore = config.DataStore, configAuthModeStrategyType = config.authModeStrategyType, configConflictHandler = config.conflictHandler, configErrorHandler = config.errorHandler, configMaxRecordsToSync = config.maxRecordsToSync, configSyncPageSize = config.syncPageSize, configFullSyncInterval = config.fullSyncInterval, configSyncExpressions = config.syncExpressions, configAuthProviders = config.authProviders, configStorageAdapter = config.storageAdapter, configFromAmplify = __rest(config, ["DataStore", "authModeStrategyType", "conflictHandler", "errorHandler", "maxRecordsToSync", "syncPageSize", "fullSyncInterval", "syncExpressions", "authProviders", "storageAdapter"]);
2058
- var apiKey = '';
2059
- var currentAppSyncConfig = (_a = core_1.Amplify.getConfig().API) === null || _a === void 0 ? void 0 : _a.AppSync;
2060
- if ((currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.defaultAuthMode.type) === 'apiKey') {
2061
- apiKey = currentAppSyncConfig.defaultAuthMode.apiKey;
2062
- }
2058
+ var currentAppSyncConfig = (_a = core_1.Amplify.getConfig().API) === null || _a === void 0 ? void 0 : _a.GraphQL;
2063
2059
  var appSyncConfig = {
2064
2060
  aws_appsync_graphqlEndpoint: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.endpoint,
2065
- aws_appsync_authenticationType: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.defaultAuthMode.type,
2061
+ aws_appsync_authenticationType: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.defaultAuthMode,
2066
2062
  aws_appsync_region: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.region,
2067
- aws_appsync_apiKey: apiKey,
2063
+ aws_appsync_apiKey: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.apiKey,
2068
2064
  };
2069
2065
  _this.amplifyConfig = __assign(__assign(__assign({}, _this.amplifyConfig), configFromAmplify), (currentAppSyncConfig && appSyncConfig));
2070
2066
  _this.conflictHandler = _this.setConflictHandler(config);
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ReachabilityMonitor = void 0;
7
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8
5
  // SPDX-License-Identifier: Apache-2.0
9
6
  var utils_1 = require("@aws-amplify/core/internals/utils");
10
- var netinfo_1 = __importDefault(require("@react-native-community/netinfo"));
11
- exports.ReachabilityMonitor = new utils_1.Reachability().networkMonitor(netinfo_1.default);
7
+ var react_native_1 = require("@aws-amplify/react-native");
8
+ exports.ReachabilityMonitor = new utils_1.Reachability().networkMonitor((0, react_native_1.loadNetInfo)());
@@ -133,7 +133,7 @@ var SubscriptionProcessor = /** @class */ (function () {
133
133
  return rule.authStrategy === 'groups' &&
134
134
  ['userPools', 'oidc'].includes(rule.provider);
135
135
  });
136
- var validGroup = authMode === 'jwt' &&
136
+ var validGroup = (authMode === 'oidc' || authMode === 'userPool') &&
137
137
  groupAuthRules.find(function (groupAuthRule) {
138
138
  // validate token against groupClaim
139
139
  if (oidcTokenPayload) {
@@ -156,7 +156,7 @@ var SubscriptionProcessor = /** @class */ (function () {
156
156
  // Owner auth needs additional values to be returned in order to create the subscription with
157
157
  // the correct parameters so we are getting the owner value from the OIDC token via the
158
158
  // identityClaim from the auth rule.
159
- var oidcOwnerAuthRules = authMode === 'jwt'
159
+ var oidcOwnerAuthRules = authMode === 'oidc' || authMode === 'userPool'
160
160
  ? rules.filter(function (rule) {
161
161
  return rule.authStrategy === 'owner' &&
162
162
  (rule.provider === 'oidc' || rule.provider === 'userPools');
@@ -169,7 +169,7 @@ var SubscriptionProcessor = /** @class */ (function () {
169
169
  var isOwnerArgRequired = singleOwner && !ownerAuthRule.areSubscriptionsPublic;
170
170
  if (ownerValue) {
171
171
  ownerAuthInfo = {
172
- authMode: 'jwt',
172
+ authMode: authMode,
173
173
  isOwner: isOwnerArgRequired,
174
174
  ownerField: ownerAuthRule.ownerField,
175
175
  ownerValue: String(ownerValue),
@@ -1,5 +1,5 @@
1
1
  import { GraphQLAuthError } from '@aws-amplify/api';
2
- import { GraphQLAuthModeKeys } from '@aws-amplify/core/internals/utils';
2
+ import { APIAuthMode } from '@aws-amplify/core/internals/utils';
3
3
  import { ModelInstanceCreator } from '../datastore/datastore';
4
4
  import { AuthorizationRule, GraphQLCondition, GraphQLFilter, ModelInstanceMetadata, OpType, PersistentModel, PersistentModelConstructor, PredicatesGroup, RelationshipType, SchemaModel, SchemaNamespace, SchemaNonModel, ModelOperation, InternalSchema, AuthModeStrategy } from '../types';
5
5
  import { MutationEvent } from './';
@@ -93,14 +93,14 @@ export declare function getUserGroupsFromToken(token: {
93
93
  }, rule: AuthorizationRule): string[];
94
94
  export declare function getModelAuthModes({ authModeStrategy, defaultAuthMode, modelName, schema, }: {
95
95
  authModeStrategy: AuthModeStrategy;
96
- defaultAuthMode: GraphQLAuthModeKeys;
96
+ defaultAuthMode: APIAuthMode;
97
97
  modelName: string;
98
98
  schema: InternalSchema;
99
99
  }): Promise<{
100
- [key in ModelOperation]: GraphQLAuthModeKeys[];
100
+ [key in ModelOperation]: APIAuthMode[];
101
101
  }>;
102
102
  export declare function getForbiddenError(error: any): any;
103
103
  export declare function getClientSideAuthError(error: any): GraphQLAuthError;
104
- export declare function getTokenForCustomAuth(authMode: GraphQLAuthModeKeys, amplifyConfig?: Record<string, any>): Promise<string | undefined>;
104
+ export declare function getTokenForCustomAuth(authMode: APIAuthMode, amplifyConfig?: Record<string, any>): Promise<string | undefined>;
105
105
  export declare function getIdentifierValue(modelDefinition: SchemaModel, model: ModelInstanceMetadata | PersistentModel): string;
106
106
  export {};