@aws-amplify/data-schema 0.18.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Authorization.js +17 -17
- package/dist/cjs/Authorization.js.map +1 -1
- package/dist/cjs/SchemaProcessor.js +6 -1
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/esm/Authorization.d.ts +16 -16
- package/dist/esm/Authorization.mjs +17 -17
- package/dist/esm/Authorization.mjs.map +1 -1
- package/dist/esm/CustomOperation.d.ts +2 -2
- package/dist/esm/SchemaProcessor.mjs +6 -1
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/runtime/bridge-types.d.ts +1 -1
- package/dist/esm/runtime/client/index.d.ts +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Authorization.ts +17 -17
- package/src/CustomOperation.ts +2 -2
- package/src/SchemaProcessor.ts +9 -1
- package/src/runtime/bridge-types.ts +1 -0
- package/src/runtime/client/index.ts +1 -0
package/package.json
CHANGED
package/src/Authorization.ts
CHANGED
|
@@ -10,11 +10,11 @@ const __data = Symbol('data');
|
|
|
10
10
|
*
|
|
11
11
|
* This list should not be used if you need to restrict available providers
|
|
12
12
|
* according to an auth strategcy. E.g., `public` auth can only be facilitated
|
|
13
|
-
* by `apiKey` and `
|
|
13
|
+
* by `apiKey` and `identityPool` providers.
|
|
14
14
|
*/
|
|
15
15
|
export const Providers = [
|
|
16
16
|
'apiKey',
|
|
17
|
-
'
|
|
17
|
+
'identityPool',
|
|
18
18
|
'userPools',
|
|
19
19
|
'oidc',
|
|
20
20
|
'function',
|
|
@@ -24,13 +24,13 @@ export type Provider = (typeof Providers)[number];
|
|
|
24
24
|
/**
|
|
25
25
|
* The subset of auth providers that can facilitate `public` auth.
|
|
26
26
|
*/
|
|
27
|
-
export const PublicProviders = ['apiKey', '
|
|
27
|
+
export const PublicProviders = ['apiKey', 'identityPool'] as const;
|
|
28
28
|
export type PublicProvider = (typeof PublicProviders)[number];
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* The subset of auth providers that can facilitate `private` auth.
|
|
32
32
|
*/
|
|
33
|
-
export const PrivateProviders = ['userPools', 'oidc', '
|
|
33
|
+
export const PrivateProviders = ['userPools', 'oidc', 'identityPool'] as const;
|
|
34
34
|
export type PrivateProvider = (typeof PrivateProviders)[number];
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -205,7 +205,7 @@ function authData<
|
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
207
|
* Defines an authorization rule for your data models and fields. First choose an authorization strategy (`public`,
|
|
208
|
-
* `private`, `owner`, `group`, or `custom`), then choose an auth provider (`apiKey`, `
|
|
208
|
+
* `private`, `owner`, `group`, or `custom`), then choose an auth provider (`apiKey`, `identitypool`, `userPools`, `oidc`, or `function`)
|
|
209
209
|
* and optionally use `.to(...)` to specify the operations that can be performed against your data models and fields.
|
|
210
210
|
*/
|
|
211
211
|
export const allow = {
|
|
@@ -226,14 +226,14 @@ export const allow = {
|
|
|
226
226
|
},
|
|
227
227
|
|
|
228
228
|
/**
|
|
229
|
-
* Authorize unauthenticated users by using
|
|
229
|
+
* Authorize unauthenticated users by using IDENTITYPOOL based authorization.
|
|
230
230
|
* @returns an authorization rule for unauthenticated users
|
|
231
231
|
*/
|
|
232
232
|
guest() {
|
|
233
233
|
return authData(
|
|
234
234
|
{
|
|
235
235
|
strategy: 'public',
|
|
236
|
-
provider: '
|
|
236
|
+
provider: 'identityPool',
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
239
|
to,
|
|
@@ -242,9 +242,9 @@ export const allow = {
|
|
|
242
242
|
},
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
|
-
* Authorize authenticated users. By default, `.
|
|
246
|
-
* use `.authenticated("
|
|
247
|
-
* @param provider the authentication provider - supports "userPools", "
|
|
245
|
+
* Authorize authenticated users. By default, `.authenticated()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
246
|
+
* use `.authenticated("identityPool")` or `.authenticated("oidc")` to use identityPool or OIDC based authorization for authenticated users.
|
|
247
|
+
* @param provider the authentication provider - supports "userPools", "identityPool", or "oidc"
|
|
248
248
|
* @returns an authorization rule for authenticated users
|
|
249
249
|
*/
|
|
250
250
|
authenticated(provider?: PrivateProvider) {
|
|
@@ -272,7 +272,7 @@ export const allow = {
|
|
|
272
272
|
* To change the specific claim that should be used as the user identifier within the owner field, chain the
|
|
273
273
|
* `.identityClaim(...)` method.
|
|
274
274
|
*
|
|
275
|
-
* @param provider the authentication provider - supports "userPools", "
|
|
275
|
+
* @param provider the authentication provider - supports "userPools", "identityPool", or "oidc"
|
|
276
276
|
* @returns an authorization rule for authenticated users
|
|
277
277
|
*/
|
|
278
278
|
owner(provider?: OwnerProviders) {
|
|
@@ -300,7 +300,7 @@ export const allow = {
|
|
|
300
300
|
* `.identityClaim(...)` method.
|
|
301
301
|
*
|
|
302
302
|
* @param ownerField the field that contains the owner information
|
|
303
|
-
* @param provider the authentication provider - supports "userPools", "
|
|
303
|
+
* @param provider the authentication provider - supports "userPools", "identityPool", or "oidc"
|
|
304
304
|
* @returns an authorization rule for authenticated users
|
|
305
305
|
*/
|
|
306
306
|
ownerDefinedIn<T extends string>(ownerField: T, provider?: OwnerProviders) {
|
|
@@ -333,7 +333,7 @@ export const allow = {
|
|
|
333
333
|
* `.identityClaim(...)` method.
|
|
334
334
|
*
|
|
335
335
|
* @param ownersField the field that contains the owners information
|
|
336
|
-
* @param provider the authentication provider - supports "userPools", "
|
|
336
|
+
* @param provider the authentication provider - supports "userPools", "identityPool", or "oidc"
|
|
337
337
|
* @returns an authorization rule for authenticated users
|
|
338
338
|
*/
|
|
339
339
|
ownersDefinedIn<T extends string>(ownersField: T, provider?: OwnerProviders) {
|
|
@@ -506,14 +506,14 @@ export const allowForCustomOperations = {
|
|
|
506
506
|
},
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
|
-
* Authorize unauthenticated users by using
|
|
509
|
+
* Authorize unauthenticated users by using identityPool based authorization.
|
|
510
510
|
* @returns an authorization rule for unauthenticated users
|
|
511
511
|
*/
|
|
512
512
|
guest() {
|
|
513
513
|
return authData(
|
|
514
514
|
{
|
|
515
515
|
strategy: 'public',
|
|
516
|
-
provider: '
|
|
516
|
+
provider: 'identityPool',
|
|
517
517
|
},
|
|
518
518
|
{},
|
|
519
519
|
);
|
|
@@ -521,8 +521,8 @@ export const allowForCustomOperations = {
|
|
|
521
521
|
|
|
522
522
|
/**
|
|
523
523
|
* Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally
|
|
524
|
-
* use `.authenticated("
|
|
525
|
-
* @param provider the authentication provider - supports "userPools", "
|
|
524
|
+
* use `.authenticated("identityPool")` or `.authenticated("oidc")` to use Identity Pool or OIDC based authorization for authenticated users.
|
|
525
|
+
* @param provider the authentication provider - supports "userPools", "identityPool", or "oidc"
|
|
526
526
|
* @returns an authorization rule for authenticated users
|
|
527
527
|
*/
|
|
528
528
|
authenticated(provider?: PrivateProvider) {
|
package/src/CustomOperation.ts
CHANGED
|
@@ -237,7 +237,7 @@ export function query(): CustomOperation<
|
|
|
237
237
|
typeName: 'Query';
|
|
238
238
|
handlers: null;
|
|
239
239
|
},
|
|
240
|
-
|
|
240
|
+
'for',
|
|
241
241
|
typeof queryBrand
|
|
242
242
|
> {
|
|
243
243
|
return _custom('Query', queryBrand);
|
|
@@ -258,7 +258,7 @@ export function mutation(): CustomOperation<
|
|
|
258
258
|
typeName: 'Mutation';
|
|
259
259
|
handlers: null;
|
|
260
260
|
},
|
|
261
|
-
|
|
261
|
+
'for',
|
|
262
262
|
typeof mutationBrand
|
|
263
263
|
> {
|
|
264
264
|
return _custom('Mutation', mutationBrand);
|
package/src/SchemaProcessor.ts
CHANGED
|
@@ -571,7 +571,9 @@ function calculateAuth(authorization: Authorization<any, any, any>[]) {
|
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
if (rule.provider) {
|
|
574
|
-
|
|
574
|
+
// identityPool maps to iam in the transform
|
|
575
|
+
const provider = rule.provider === 'identityPool' ? 'iam' : rule.provider;
|
|
576
|
+
ruleParts.push(`provider: ${provider}`);
|
|
575
577
|
}
|
|
576
578
|
|
|
577
579
|
if (rule.operations) {
|
|
@@ -1270,6 +1272,12 @@ function validateCustomOperations(
|
|
|
1270
1272
|
}
|
|
1271
1273
|
}
|
|
1272
1274
|
|
|
1275
|
+
if (opType !== 'Subscription' && subscriptionSource.length > 0) {
|
|
1276
|
+
throw new Error(
|
|
1277
|
+
`The .for() modifier function can only be used with a custom subscription. ${typeName} is not a custom subscription.`,
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1273
1281
|
if (opType === 'Subscription') {
|
|
1274
1282
|
if (subscriptionSource.length < 1) {
|
|
1275
1283
|
throw new Error(
|