Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
182 changes: 15 additions & 167 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@ utilising the solidpod package.

## Introduction

[SolidPod](https://pub.dev/packages/solidpod) provides functionality
for dart applications to manage personal online data stores (Pods)
hosted in a Data Vault on a [Solid
Server](https://solidproject.org). The package provides underlying
functionality relied upon by the
[solidui](https://pub.dev/packages/solidui) package for quickly
building Flutter-based applications. It supports high level access
for an application to authenticate users to their Pods, access the
users' data from their Pods, and then share the data stored in users'
Pods with other Pods through Flutter Widgets.
[SolidPod](https://pub.dev/packages/solidpod) provides the core
business logic for Dart applications to manage personal online data
stores (PODs) hosted in a Data Vault on a [Solid
Server](https://solidproject.org). It supports authenticating users to
their PODs, reading and writing data, and managing access permissions
programmatically. The companion
[solidui](https://pub.dev/packages/solidui) package builds on top of
SolidPod to provide ready-made Flutter widgets for login screens,
permission management, and other user-facing features.

## What is Solid?

Expand All @@ -55,15 +54,15 @@ visit <https://solidcommunity.au>

## Features

- [Authenticate](#authenticate-example) a user against a given Solid server
and [login](#login-example).
- [Manage security key](#change-security-key-example) for data encryption.
- [Authenticate](#authenticate-example) a user against a given Solid server.
- [Read](#read-pod-file-example) and [write](#write-to-pod-file-example) data files
in POD.
- [View](#view-permission-ui-example) and [manage](#grant-permission-ui-example)
file access permissions.
in a POD.
- [Read, write and delete](#large-file-manager-example) large data files.

For UI components such as login screens, security key management,
permission granting/revoking, and shared resource views, see the
[solidui](https://pub.dev/packages/solidui) package.

[Solid](https://solidproject.org/) is an open standard for a server
providing Data Vaults hosting personal online data stores
(Pods). Numerous providers of Solid Server
Expand Down Expand Up @@ -198,39 +197,6 @@ final authData = await solidAuthenticate(
);
```

### Login Example

A simple login screen to authenticate a user against a Solid server.
If your own home widget is called `MyHome()` then simply wrap this within
the `SolidLogin()` widget:

```dart
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My Pod',
home: const SolidLogin(
child: Scaffold(body: MyHome()),
),
);
}
```

### Change Security Key Example

Wrap the `changeKeyPopup()` function within a button widget. Parameters
include the `BuildContext` and the widget that you need to return to
after changing the key.

```dart
ElevatedButton(
onPressed: () {
changeKeyPopup(context, ReturnPage());
},
child: const Text('Change Security Key on Pod')
)
```

### Read Pod File Example

Read data from the file `data/myfiles/my-data-file.ttl`.
Expand Down Expand Up @@ -292,124 +258,6 @@ The above will create a single `.acl` file for the directory
`child-2.ttl` files. Also it will create a single key associated with
the directory `parentDir` and encrypt both files using that key.

### Grant Permission UI Example

Wrap the `GrantPermissionUi` widget around a button to navigate to
the grant permission page.

```dart
ElevatedButton(
child: const Text(
'Add/Delete Permissions'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const GrantPermissionUi(
child: ReturnPage(),
),
),
),
)
```

To add/delete permissions of a recipient to a specific user owned file use:

```dart
ElevatedButton(
child: const Text(
'Add/Delete Permissions from a Specific File'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const GrantPermissionUi(
resourceName: 'my-data-file.ttl',
child: ReturnPage(),
),
),
),
)
```

To add/delete permissions of a recipient to a specific user owned directory use:

```dart
ElevatedButton(
child: const Text(
'Add/Delete Permissions from a Specific Directory'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const GrantPermissionUi(
resourceName: 'parentDir/',
child: ReturnPage(),
isFile: false,
),
),
),
)
```

To add/delete permissions of a recipient to a specific externally owned
file (that user has control access to) use:

```dart
ElevatedButton(
child: const Text(
'Add/Delete Permissions from a Specific File'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const GrantPermissionUi(
resourceName: 'my-data-file.ttl',
isExternalRes: true,
ownerWebId: ownerWebId,
granterWebId: granterWebId,
child: ReturnPage(),
),
),
),
)
```

### View Permission UI Example

Wrap the `SharedResourcesUi` widget around a button to navigate to
the view permission page.

```dart
ElevatedButton(
child: const Text(
'View Resources your WebID have access to'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SharedResourcesUi(
child: ReturnPage(),
),
),
),
)
```

To view permissions to a specific resource from a specific webID use:

```dart
ElevatedButton(
child: const Text(
'View access to specific Resource'),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SharedResourcesUi(
fileName: 'my-data-file.ttl',
sourceWebId: 'https://pods.solidcommunity.au/john-doe/profile/card#me',
child: ReturnPage(),
),
),
),
)
```

### Large File Manager Example

To upload a large file in application `myapp`, use:
Expand Down
1 change: 1 addition & 0 deletions example/lib/features/permission_callback_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ library;
import 'package:flutter/material.dart';

import 'package:solidpod/solidpod.dart';
import 'package:solidui/solidui.dart' show GrantPermissionUi;

/// A widget demonstrating the onPermissionGranted callback functionality.

Expand Down
10 changes: 6 additions & 4 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ import 'package:markdown_tooltip/markdown_tooltip.dart';
import 'package:solidpod/solidpod.dart';
import 'package:solidui/solidui.dart'
show
GrantPermissionUi,
InitialSetupScreenBody,
SharedResourcesUi,
changeKeyPopup,
getKeyFromUserIfRequired,
largeGapV,
loginIfRequired,
logoutPopup,
getKeyFromUserIfRequired,
changeKeyPopup,
smallGapV,
largeGapV;
smallGapV;

import 'package:demopod/constants/app.dart';
import 'package:demopod/dialogs/about.dart';
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependency_overrides:
solidui:
git:
url: https://github.com/anusii/solidui
ref: dev
ref: tony/59_ui_migration

dev_dependencies:
flutter_lints: ^6.0.0
Expand Down
59 changes: 44 additions & 15 deletions lib/solidpod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export 'src/solid/constants/solid_constants.dart';

// Legacy exports for backward compatibility (deprecated, use SolidConstants instead)

export 'src/solid/constants/common.dart' show foaf, terms, ResourceStatus;
export 'src/solid/constants/common.dart'
show foaf, terms, ResourceStatus, permStr, agentStr, whatIsWebID, demoWebID;
export 'src/solid/constants/schema.dart' show appsTerms;
export 'src/solid/constants/path_type.dart' show PathType;

Expand All @@ -50,14 +51,6 @@ export 'src/solid/constants/predicates.dart';

export 'src/solid/authenticate.dart' show solidAuthenticate;

/// UI class to grant permission for a resource

export 'src/solid/grant_permission_ui.dart';

/// UI class to read permission given to the user webID by others

export 'src/solid/shared_resources_ui.dart';

/// Status class to represent different function outputs

export 'src/solid/solid_func_call_status.dart' show SolidFunctionCallStatus;
Expand Down Expand Up @@ -118,6 +111,7 @@ export 'src/solid/utils/misc.dart'
getTokensForResource,
getDateTime,
getEncKeyPath,
isDir,
logoutPod,
registerLogoutCacheCallback,
setAppDirName,
Expand Down Expand Up @@ -165,8 +159,15 @@ export 'src/solid/read_permission.dart';

export 'src/solid/revoke_permission.dart';

/// Permission recipient type
export 'src/solid/constants/web_acl.dart' show RecipientType;
/// Permission types and access control utilities
export 'src/solid/constants/web_acl.dart'
show
RecipientType,
AccessMode,
getRecipientType,
getAccessMode,
publicAgent,
authenticatedAgent;

/// Functions to upload, download, and delete large file from a Solid server

Expand Down Expand Up @@ -223,8 +224,36 @@ export 'src/solid/constants/common.dart' show dataDir, profCard, authUserPred;

export 'src/solid/get_resources.dart';

/// 20250917 gjw Extras that were required for the example app! Not yet
/// documented.
/// Check if a resource exists and has an associated ACL file

export 'src/solid/chk_exists_and_has_acl.dart' show chkExistsAndHasAcl;

/// Retrieve the list of recipients that have access to files in a user's POD

export 'src/solid/get_recipient_list.dart'
show getRecipientList, extractRecipWebIdList;

/// Read permission history of a resource

export 'src/solid/shared_resource_history.dart' show sharedResourcesHistory;

/// Standardise retrieval of authoriser (owner or granter) for a resource

export 'src/solid/utils/get_authoriser.dart' show getAuthoriser;

/// Data model for permission details

export 'src/solid/models/permission_details.dart' show PermissionDetails;

/// Utilities for parsing permission data into the Permission model

export 'src/solid/utils/permission_helper.dart'
show PermissionHelper, permMapToList;

/// Data model for log records (permission history entries)

export 'src/solid/models/log_record.dart' show LogRecord;

/// Data model for parsed permission entries

export 'package:solidui/solidui.dart'
show SecurityKeyUI, SecurityStrings, changeKeyPopup;
export 'src/solid/models/permission.dart' show Permission;
23 changes: 22 additions & 1 deletion lib/src/solid/common_func.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import 'package:flutter/material.dart';
import 'package:solidpod/src/solid/api/rest_api.dart';
import 'package:solidpod/src/solid/constants/common.dart';
import 'package:solidpod/src/solid/constants/schema.dart' show appsTerms;
import 'package:solidpod/src/solid/utils/alert.dart';
import 'package:solidpod/src/solid/utils/exceptions.dart';
import 'package:solidpod/src/solid/utils/get_url_helper.dart';
import 'package:solidpod/src/solid/utils/init_helper.dart';
Expand Down Expand Up @@ -130,6 +129,28 @@ Future<void> deleteDataFileDialog(
if (context.mounted) await alert(context, msg);
}

/// Show a simple alert dialog with a message and an optional title.

Future<void> alert(
BuildContext context,
String msg, [
String title = 'Notice',
]) async {
await showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(title),
content: Text(msg),
actions: [
ElevatedButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
}

/// Get inherited resource parent directory url
String getParentDir(String fileContent, String fileUrl) {
final dataMap = parseTTLMap(fileContent);
Expand Down
Loading