Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Flutter Gen2 fixes #7738

Merged
merged 27 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ed1440e
chore: update mfa page to change flutter snippets from js to dart
khatruong2009 Jun 11, 2024
0dd901e
chore: combine duplicate sms mfa text from swift and flutter
khatruong2009 Jun 12, 2024
cbbfaa9
chore: added flutter snippet for global sign out
khatruong2009 Jun 12, 2024
a2e94d3
chore: fix sign up next steps from enums to flutter
khatruong2009 Jun 12, 2024
cc41aae
chore: fix outputs to amplify config in _configureAmplify method
khatruong2009 Jun 12, 2024
41c906b
chore: fix flutter sign in next steps from using enums
khatruong2009 Jun 12, 2024
0f25283
chore: add APIPluginOptions
khatruong2009 Jun 12, 2024
19c6d40
chore: add view analytics console
khatruong2009 Jun 12, 2024
76c2f55
chore: add user agent back into json in analytics record event page
khatruong2009 Jun 12, 2024
162d8aa
chore: fix automated reconnection snippet to use APIPluginOptions
khatruong2009 Jun 13, 2024
4348e5d
chore: remove next.js related page and snippets from data
khatruong2009 Jun 13, 2024
113c5d1
chore: add flutter snippet to customize auth rules public data access
khatruong2009 Jun 13, 2024
eb12ead
chore: remove duplicate lines of code between swift and
khatruong2009 Jun 13, 2024
377e72f
chore: replace js code snippet with flutter for per user data access
khatruong2009 Jun 13, 2024
418998a
chore: replace js snippets with flutter for multi-user data access
khatruong2009 Jun 13, 2024
918b67f
chore: replaced js snippets in signed-in user data access with flutte…
khatruong2009 Jun 13, 2024
7a6bcfc
chore: replace js snippets with flutter snippets in user group-based …
khatruong2009 Jun 13, 2024
097a1d2
chore: replace js snippet with flutter snippets in custom data access…
khatruong2009 Jun 13, 2024
bc89a52
chore: replaced js snippet with flutter snippet in use openID Connect…
khatruong2009 Jun 14, 2024
938e5d1
chore: replace js snippets with flutter snippets in configure custom …
khatruong2009 Jun 14, 2024
420ac5c
chore: fixed amplifyconfig and replaced with ApmlifyConfig
khatruong2009 Jun 17, 2024
7d2a9d4
Update src/pages/[platform]/build-a-backend/data/customize-authz/conf…
khatruong2009 Jun 17, 2024
88cc424
chore: fix API code snippets
khatruong2009 Jun 17, 2024
7b0b281
Update src/pages/[platform]/build-a-backend/data/set-up-data/index.mdx
khatruong2009 Jun 17, 2024
32c91b3
chore: fixed multi-user-data-access code and replaced with flutter code
khatruong2009 Jun 17, 2024
2071472
chore: revert changes in gen1 docs
khatruong2009 Jun 17, 2024
a7e38b5
chore: remove gen1 remnants for analytics category
khatruong2009 Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,14 @@ class InMemoryStorage implements SecureStorageInterface {
</InlineFilter>

## Token Revocation
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "vue", "android", "flutter"]}>
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "vue", "android"]}>
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.
</InlineFilter>

<InlineFilter filters={["flutter"]}>
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.
</InlineFilter>

<InlineFilter filters={["swift"]}>
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.
</InlineFilter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func signIn(username: String, password: String) -> AnyCancellable {

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:

<InlineFilter filters={["angular", "javascript", "react", "nextjs", "vue", "flutter", "android"]}>
<InlineFilter filters={["angular", "javascript", "react", "nextjs", "vue", "android"]}>
- `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`.
- `CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE` - The sign-in must be confirmed with a custom challenge response. Complete the process with `confirmSignIn`.
- `CONFIRM_SIGN_IN_WITH_TOTP_CODE` - The sign-in must be confirmed with a TOTP code from the user. Complete the process with `confirmSignIn`.
Expand All @@ -265,7 +265,7 @@ The `signIn` API response will include a `nextStep` property, which can be used
- `DONE` - The sign in process has been completed.
</InlineFilter>

<InlineFilter filters={["swift"]}>
<InlineFilter filters={["swift", "flutter"]}>
- `confirmSignInWithNewPassword` - The user was created with a temporary password and must set a new one. Complete the process with `confirmSignIn`.
- `confirmSignInWithCustomChallenge` - The sign-in must be confirmed with a custom challenge response. Complete the process with `confirmSignIn`.
- `confirmSignInWithTOTPCode` - The sign-in must be confirmed with a TOTP code from the user. Complete the process with `confirmSignIn`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@ func signUp(username: String, password: String, email: String, phonenumber: Stri

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:

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

<InlineFilter filters={["swift"]}>
<InlineFilter filters={["swift", "flutter"]}>
- `confirmUser` - The sign up needs to be confirmed by collecting a code from the user and calling `confirmSignUp` API.
- `done` - The sign up process has been fully completed.
</InlineFilter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Future<void> main() async {
Future<void> _configureAmplify() async {
try {
await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.configure(outputs);
await Amplify.configure(amplifyConfig);
safePrint('Successfully configured');
} on Exception catch (e) {
safePrint('Error configuring Amplify: $e');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const meta = {
platforms: [
'android',
'angular',
'flutter',
'javascript',
'nextjs',
'react',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const meta = {
platforms: [
'android',
'angular',
'flutter',
'javascript',
'nextjs',
'react',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export const data = defineData({ schema });

```

<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android", "swift"]}>

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

```ts
Expand All @@ -76,3 +78,29 @@ const { errors, data: newTodo } = await client.models.Todo.create(
// highlight-end
);
```

</InlineFilter>

<InlineFilter filters={["flutter"]}>
In your application, you can perform CRUD operations against the model with the `userPools` auth mode.
khatruong2009 marked this conversation as resolved.
Show resolved Hide resolved

```dart
try {
final todo = Todo(content: 'My new todo');
final request = ModelMutations.create(
todo,
authorizationMode: APIAuthorizationType.userPools,
);
final createdTodo = await Amplify.API.mutations(request: request).response;

if (createdTodo == null) {
safePrint('errors: ${response.errors}');
return;
}
safePrint('Mutation result: ${createdTodo.name}');

} on APIException catch (e) {
safePrint('Failed to create todo', e);
}
```
</InlineFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const data = defineData({
},
});
```
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue", "android", "swift"]}>

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

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

</InlineFilter>

<InlineFilter filters={["flutter"]}>
In your application, you can perform CRUD operations against the model with the `function` auth mode.

```dart
try {
final todo = Todo(content: 'My new todo');
final request = ModelMutations.create(
todo,
authorizationMode: APIAuthorizationType.function,
);
final createdTodo = await Amplify.API.mutations(request: request).response;

if (createdTodo == null) {
safePrint('errors: ${response.errors}');
return;
}
safePrint('Mutation result: ${createdTodo.name}');

} on APIException catch (e) {
safePrint('Failed to create todo', e);
}
```

</InlineFilter>

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.

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const schema = a.schema({
});
```

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

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

Expand Down Expand Up @@ -88,6 +88,51 @@ await client.models.Todo.update(

</InlineFilter>

<InlineFilter filters={["flutter"]}>
In your application, you can perform CRUD operations against the model with the `userPools` auth mode.

```dart
try {
final todo = Todo(content: 'My new todo');
final request = ModelMutations.create(
todo,
authorizationMode: APIAuthorizationType.userPools,
);
final createdTodo = await Amplify.API.mutations(request: request).response;

if (createdTodo == null) {
safePrint('errors: ${response.errors}');
return;
}
safePrint('Mutation result: ${createdTodo.name}');

} on APIException catch (e) {
safePrint('Failed to create todo', e);
}
```

Add another user as an owner

```dart
try {
createdTodo.owners!.add(otherUserId);
let updateRequest = ModelMutations.update(
createdTodo,
authorizationMode: APIAuthorizationType.userPools,
);
final updatedTodo = await Amplify.API.mutations(request: updateRequest).response;

if (updatedTodo == null) {
safePrint('errors: ${response.errors}');
return;
}

} catch {
safePrint("Failed to update todo", error)
}
```
</InlineFilter>

<InlineFilter filters={["swift"]}>

In your application, you can perform CRUD operations against the model with the `amazonCognitoUserPools` auth mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const schema = a.schema({
});
```

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

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

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

<InlineFilter filters={["flutter"]}>
In your application, you can perform CRUD operations against the model with the `userPools` auth mode.

```dart
try {
final todo = Todo(content: 'My new todo');
final request = ModelMutations.create(
todo,
authorizationMode: APIAuthorizationType.userPools,
);
final createdTodo = await Amplify.API.mutations(request: request).response;

if (createdTodo == null) {
safePrint('errors: ${response.errors}');
return;
}
safePrint('Mutation result: ${createdTodo.name}');

} on APIException catch (e) {
safePrint('Failed to create todo', e);
}
```
</InlineFilter>

<InlineFilter filters={["swift"]}>

In your application, you can perform CRUD operations against the model with the `amazonCognitoUserPools` auth mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const schema = a.schema({
});
```

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

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

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

</InlineFilter>

<InlineFilter filters={["swift"]}>

<InlineFilter filters={["swift", "flutter"]}>
In your application, you can perform CRUD operations against the model by specifying the `apiKey` auth mode.
</InlineFilter>

<InlineFilter filters={["flutter"]}>

```dart
try {
final todo = Todo(content: 'My new todo');
final request = ModelMutations.create(
todo,
authorizationMode: APIAuthorizationType.apiKey,
);
final createdTodo = await Amplify.API.mutations(request: request).response;

if (createdTodo == null) {
safePrint('errors: ${response.errors}');
return;
}
safePrint('Mutation result: ${createdTodo.name}');

} on APIException catch (e) {
safePrint('Failed to create todo', e);
}
```

</InlineFilter>

<InlineFilter filters={["swift"]}>

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

</InlineFilter>

<InlineFilter filters={["swift"]}>
<InlineFilter filters={["flutter"]}>
In your application, you can perform CRUD operations against the model with the `iam` auth mode.

```dart
try {
final todo = Todo(content: 'My new todo');
final request = ModelMutations.create(
todo,
authorizationMode: APIAuthorizationType.iam,
);
final createdTodo = await Amplify.API.mutations(request: request).response;

if (createdTodo == null) {
safePrint('errors: ${response.errors}');
return;
}
safePrint('Mutation result: ${createdTodo.name}');

} on APIException catch (e) {
safePrint('Failed to create todo', e);
}
```

</InlineFilter>

<InlineFilter filters={["swift"]}>
In your application, you can perform CRUD operations against the model with the `awsIAM` auth mode.

```swift
Expand Down
Loading
Loading