Skip to content

Commit 632c581

Browse files
chore: Flutter Gen2 fixes (#7738)
* chore: update mfa page to change flutter snippets from js to dart * chore: combine duplicate sms mfa text from swift and flutter * chore: added flutter snippet for global sign out * chore: fix sign up next steps from enums to flutter * chore: fix outputs to amplify config in _configureAmplify method * chore: fix flutter sign in next steps from using enums * chore: add APIPluginOptions * chore: add view analytics console * chore: add user agent back into json in analytics record event page * chore: fix automated reconnection snippet to use APIPluginOptions * chore: remove next.js related page and snippets from data * chore: add flutter snippet to customize auth rules public data access * chore: remove duplicate lines of code between swift and * chore: replace js code snippet with flutter for per user data access * chore: replace js snippets with flutter for multi-user data access * chore: replaced js snippets in signed-in user data access with flutter snippets * chore: replace js snippets with flutter snippets in user group-based data access * chore: replace js snippet with flutter snippets in custom data access using lambda functions page * chore: replaced js snippet with flutter snippet in use openID Connect as an authorization provider page * chore: replace js snippets with flutter snippets in configure custom identity and group claims page * chore: fixed amplifyconfig and replaced with ApmlifyConfig * Update src/pages/[platform]/build-a-backend/data/customize-authz/configure-custom-identity-and-group-claim/index.mdx Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com> * chore: fix API code snippets * Update src/pages/[platform]/build-a-backend/data/set-up-data/index.mdx Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com> * chore: fixed multi-user-data-access code and replaced with flutter code * chore: revert changes in gen1 docs * chore: remove gen1 remnants for analytics category --------- Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
1 parent 53d9afe commit 632c581

File tree

17 files changed

+536
-40
lines changed

17 files changed

+536
-40
lines changed

src/pages/[platform]/build-a-backend/auth/concepts/multi-factor-authentication/index.mdx

Lines changed: 228 additions & 17 deletions
Large diffs are not rendered by default.

src/pages/[platform]/build-a-backend/auth/concepts/tokens-and-credentials/index.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,14 @@ class InMemoryStorage implements SecureStorageInterface {
253253
</InlineFilter>
254254

255255
## Token Revocation
256-
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "vue", "android", "flutter"]}>
256+
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "vue", "android"]}>
257257
Token revocation is enabled automatically in Amplify Auth. To revoke tokens you can set up global sign-out with `signOut({ global: true })` to globally sign out your user from all of their devices.
258258
</InlineFilter>
259259

260+
<InlineFilter filters={["flutter"]}>
261+
Token revocation is enabled automatically in Amplify Auth. To revoke tokens you can invoke `await Amplify.Auth.signOut(options: const signOutOptions(globalSignOut: true))` to globally sign out your user from all of their devices.
262+
</InlineFilter>
263+
260264
<InlineFilter filters={["swift"]}>
261265
Token revocation is enabled automatically in Amplify Auth. To revoke tokens you can invoke `await Amplify.Auth.signOut(options: .init(globalSignOut: true))` to globally sign out your user from all of their devices.
262266
</InlineFilter>

src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func signIn(username: String, password: String) -> AnyCancellable {
253253

254254
The `signIn` API response will include a `nextStep` property, which can be used to determine if further action is required. It may return the following next steps:
255255

256-
<InlineFilter filters={["angular", "javascript", "react", "nextjs", "vue", "flutter", "android"]}>
256+
<InlineFilter filters={["angular", "javascript", "react", "nextjs", "vue", "android"]}>
257257
- `CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED` - The user was created with a temporary password and must set a new one. Complete the process with `confirmSignIn`.
258258
- `CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE` - The sign-in must be confirmed with a custom challenge response. Complete the process with `confirmSignIn`.
259259
- `CONFIRM_SIGN_IN_WITH_TOTP_CODE` - The sign-in must be confirmed with a TOTP code from the user. Complete the process with `confirmSignIn`.
@@ -265,7 +265,7 @@ The `signIn` API response will include a `nextStep` property, which can be used
265265
- `DONE` - The sign in process has been completed.
266266
</InlineFilter>
267267

268-
<InlineFilter filters={["swift"]}>
268+
<InlineFilter filters={["swift", "flutter"]}>
269269
- `confirmSignInWithNewPassword` - The user was created with a temporary password and must set a new one. Complete the process with `confirmSignIn`.
270270
- `confirmSignInWithCustomChallenge` - The sign-in must be confirmed with a custom challenge response. Complete the process with `confirmSignIn`.
271271
- `confirmSignInWithTOTPCode` - The sign-in must be confirmed with a TOTP code from the user. Complete the process with `confirmSignIn`.

src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-up/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ func signUp(username: String, password: String, email: String, phonenumber: Stri
285285

286286
The `signUp` API response will include a `nextStep` property, which can be used to determine if further action is required. It may return the following next steps:
287287

288-
<InlineFilter filters={["angular", "javascript", "react", "nextjs", "vue", "flutter", "android"]}>
288+
<InlineFilter filters={["angular", "javascript", "react", "nextjs", "vue", "android"]}>
289289
- `CONFIRM_SIGN_UP` - The sign up needs to be confirmed by collecting a code from the user and calling `confirmSignUp`.
290290
- `DONE` - The sign up process has been fully completed.
291291
- `COMPLETE_AUTO_SIGN_IN` - The sign up process needs to complete by invoking the `autoSignIn` API.
292292
</InlineFilter>
293293

294-
<InlineFilter filters={["swift"]}>
294+
<InlineFilter filters={["swift", "flutter"]}>
295295
- `confirmUser` - The sign up needs to be confirmed by collecting a code from the user and calling `confirmSignUp` API.
296296
- `done` - The sign up process has been fully completed.
297297
</InlineFilter>

src/pages/[platform]/build-a-backend/auth/set-up-auth/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ Future<void> main() async {
410410
Future<void> _configureAmplify() async {
411411
try {
412412
await Amplify.addPlugin(AmplifyAuthCognito());
413-
await Amplify.configure(outputs);
413+
await Amplify.configure(amplifyConfig);
414414
safePrint('Successfully configured');
415415
} on Exception catch (e) {
416416
safePrint('Error configuring Amplify: $e');

src/pages/[platform]/build-a-backend/data/connect-from-server-runtime/index.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const meta = {
99
platforms: [
1010
'android',
1111
'angular',
12-
'flutter',
1312
'javascript',
1413
'nextjs',
1514
'react',

src/pages/[platform]/build-a-backend/data/connect-from-server-runtime/nextjs-server-runtime/index.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const meta = {
77
platforms: [
88
'android',
99
'angular',
10-
'flutter',
1110
'javascript',
1211
'nextjs',
1312
'react',

src/pages/[platform]/build-a-backend/data/customize-authz/configure-custom-identity-and-group-claim/index.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export const data = defineData({ schema });
5656

5757
```
5858

59+
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android", "swift"]}>
60+
5961
In your application, you can perform CRUD operations against the model using `client.models.<model-name>` with the `userPool` auth mode.
6062

6163
```ts
@@ -76,3 +78,29 @@ const { errors, data: newTodo } = await client.models.Todo.create(
7678
// highlight-end
7779
);
7880
```
81+
82+
</InlineFilter>
83+
84+
<InlineFilter filters={["flutter"]}>
85+
In your application, you can perform CRUD operations against the model with the `userPools` auth mode.
86+
87+
```dart
88+
try {
89+
final todo = Todo(content: 'My new todo');
90+
final request = ModelMutations.create(
91+
todo,
92+
authorizationMode: APIAuthorizationType.userPools,
93+
);
94+
final createdTodo = await Amplify.API.mutations(request: request).response;
95+
96+
if (createdTodo == null) {
97+
safePrint('errors: ${response.errors}');
98+
return;
99+
}
100+
safePrint('Mutation result: ${createdTodo.name}');
101+
102+
} on APIException catch (e) {
103+
safePrint('Failed to create todo', e);
104+
}
105+
```
106+
</InlineFilter>

src/pages/[platform]/build-a-backend/data/customize-authz/custom-data-access-patterns/index.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const data = defineData({
6868
},
6969
});
7070
```
71+
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android", "swift"]}>
7172

7273
In your application, you can perform CRUD operations against the model using `client.models.<model-name>` with the `lambda` auth mode.
7374

@@ -89,6 +90,33 @@ const { errors, data: newTodo } = await client.models.Todo.create(
8990
);
9091
```
9192

93+
</InlineFilter>
94+
95+
<InlineFilter filters={["flutter"]}>
96+
In your application, you can perform CRUD operations against the model with the `function` auth mode.
97+
98+
```dart
99+
try {
100+
final todo = Todo(content: 'My new todo');
101+
final request = ModelMutations.create(
102+
todo,
103+
authorizationMode: APIAuthorizationType.function,
104+
);
105+
final createdTodo = await Amplify.API.mutations(request: request).response;
106+
107+
if (createdTodo == null) {
108+
safePrint('errors: ${response.errors}');
109+
return;
110+
}
111+
safePrint('Mutation result: ${createdTodo.name}');
112+
113+
} on APIException catch (e) {
114+
safePrint('Failed to create todo', e);
115+
}
116+
```
117+
118+
</InlineFilter>
119+
92120
The Lambda function of choice will receive an authorization token from the client and execute the desired authorization logic. The AppSync GraphQL API will receive a payload from Lambda after invocation to allow or deny the API call accordingly.
93121

94122
To configure a Lambda function as the authorization mode, create a new file `amplify/data/custom-authorizer.ts`. You can use this Lambda function code template as a starting point for your authorization handler code:

src/pages/[platform]/build-a-backend/data/customize-authz/multi-user-data-access/index.mdx

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const schema = a.schema({
4747
});
4848
```
4949

50-
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android", "flutter"]}>
50+
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android"]}>
5151

5252
In your application, you can perform CRUD operations against the model using `client.models.<model-name>` with the `userPool` auth mode.
5353

@@ -88,6 +88,51 @@ await client.models.Todo.update(
8888

8989
</InlineFilter>
9090

91+
<InlineFilter filters={["flutter"]}>
92+
In your application, you can perform CRUD operations against the model with the `userPools` auth mode.
93+
94+
```dart
95+
try {
96+
final todo = Todo(content: 'My new todo');
97+
final request = ModelMutations.create(
98+
todo,
99+
authorizationMode: APIAuthorizationType.userPools,
100+
);
101+
final createdTodo = await Amplify.API.mutations(request: request).response;
102+
103+
if (createdTodo == null) {
104+
safePrint('errors: ${response.errors}');
105+
return;
106+
}
107+
safePrint('Mutation result: ${createdTodo.name}');
108+
109+
} on APIException catch (e) {
110+
safePrint('Failed to create todo', e);
111+
}
112+
```
113+
114+
Add another user as an owner
115+
116+
```dart
117+
try {
118+
createdTodo.owners!.add(otherUserId);
119+
let updateRequest = ModelMutations.update(
120+
createdTodo,
121+
authorizationMode: APIAuthorizationType.userPools,
122+
);
123+
final updatedTodo = await Amplify.API.mutations(request: updateRequest).response;
124+
125+
if (updatedTodo == null) {
126+
safePrint('errors: ${response.errors}');
127+
return;
128+
}
129+
130+
} catch {
131+
safePrint("Failed to update todo", error)
132+
}
133+
```
134+
</InlineFilter>
135+
91136
<InlineFilter filters={["swift"]}>
92137

93138
In your application, you can perform CRUD operations against the model with the `amazonCognitoUserPools` auth mode.

src/pages/[platform]/build-a-backend/data/customize-authz/per-user-per-owner-data-access/index.mdx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const schema = a.schema({
5959
});
6060
```
6161

62-
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android", "flutter"]}>
62+
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android"]}>
6363

6464
In your application, you can perform CRUD operations against the model using `client.models.<model-name>` with the `userPool` auth mode.
6565

@@ -82,6 +82,30 @@ const { errors, data: newTodo } = await client.models.Todo.create(
8282
```
8383
</InlineFilter>
8484

85+
<InlineFilter filters={["flutter"]}>
86+
In your application, you can perform CRUD operations against the model with the `userPools` auth mode.
87+
88+
```dart
89+
try {
90+
final todo = Todo(content: 'My new todo');
91+
final request = ModelMutations.create(
92+
todo,
93+
authorizationMode: APIAuthorizationType.userPools,
94+
);
95+
final createdTodo = await Amplify.API.mutations(request: request).response;
96+
97+
if (createdTodo == null) {
98+
safePrint('errors: ${response.errors}');
99+
return;
100+
}
101+
safePrint('Mutation result: ${createdTodo.name}');
102+
103+
} on APIException catch (e) {
104+
safePrint('Failed to create todo', e);
105+
}
106+
```
107+
</InlineFilter>
108+
85109
<InlineFilter filters={["swift"]}>
86110

87111
In your application, you can perform CRUD operations against the model with the `amazonCognitoUserPools` auth mode.

src/pages/[platform]/build-a-backend/data/customize-authz/public-data-access/index.mdx

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const schema = a.schema({
4545
});
4646
```
4747

48-
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android", "flutter"]}>
48+
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android"]}>
4949

5050
In your application, you can perform CRUD operations against the model using `client.models.<model-name>` by specifying the `apiKey` auth mode.
5151

@@ -69,9 +69,35 @@ const { errors, data: newTodo } = await client.models.Todo.create(
6969

7070
</InlineFilter>
7171

72-
<InlineFilter filters={["swift"]}>
73-
72+
<InlineFilter filters={["swift", "flutter"]}>
7473
In your application, you can perform CRUD operations against the model by specifying the `apiKey` auth mode.
74+
</InlineFilter>
75+
76+
<InlineFilter filters={["flutter"]}>
77+
78+
```dart
79+
try {
80+
final todo = Todo(content: 'My new todo');
81+
final request = ModelMutations.create(
82+
todo,
83+
authorizationMode: APIAuthorizationType.apiKey,
84+
);
85+
final createdTodo = await Amplify.API.mutations(request: request).response;
86+
87+
if (createdTodo == null) {
88+
safePrint('errors: ${response.errors}');
89+
return;
90+
}
91+
safePrint('Mutation result: ${createdTodo.name}');
92+
93+
} on APIException catch (e) {
94+
safePrint('Failed to create todo', e);
95+
}
96+
```
97+
98+
</InlineFilter>
99+
100+
<InlineFilter filters={["swift"]}>
75101

76102
```swift
77103
do {
@@ -149,8 +175,32 @@ const { errors, data: newTodo } = await client.models.Todo.create(
149175

150176
</InlineFilter>
151177

152-
<InlineFilter filters={["swift"]}>
178+
<InlineFilter filters={["flutter"]}>
179+
In your application, you can perform CRUD operations against the model with the `iam` auth mode.
180+
181+
```dart
182+
try {
183+
final todo = Todo(content: 'My new todo');
184+
final request = ModelMutations.create(
185+
todo,
186+
authorizationMode: APIAuthorizationType.iam,
187+
);
188+
final createdTodo = await Amplify.API.mutations(request: request).response;
189+
190+
if (createdTodo == null) {
191+
safePrint('errors: ${response.errors}');
192+
return;
193+
}
194+
safePrint('Mutation result: ${createdTodo.name}');
153195
196+
} on APIException catch (e) {
197+
safePrint('Failed to create todo', e);
198+
}
199+
```
200+
201+
</InlineFilter>
202+
203+
<InlineFilter filters={["swift"]}>
154204
In your application, you can perform CRUD operations against the model with the `awsIAM` auth mode.
155205

156206
```swift

0 commit comments

Comments
 (0)