Skip to content

Commit

Permalink
Merge pull request #3236 from numbersprotocol/v240305-capture-cam-ionic
Browse files Browse the repository at this point in the history
V240305 capture cam ionic
  • Loading branch information
shc261392 committed Mar 8, 2024
2 parents 2868ea0 + f43e46a commit f5028f3
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 12 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.90.0] - 2024-03-08

### Added

1. Feature sort assets in VERIFIED tab by uploaded at [#3233](https://github.com/numbersprotocol/capture-lite/pull/3233)
1. Feature pass x api key to get app info [#3231](https://github.com/numbersprotocol/capture-lite/pull/3231)

## [0.89.2] - 2024-02-21

### Fixed
Expand Down Expand Up @@ -2263,7 +2270,8 @@ This is the first release! _Capture Lite_ is a cross-platform app adapted from [
- Web - see the demo [here](https://github.com/numbersprotocol/capture-lite#demo-app)
- Android - the APK file `app-debug.apk` is attached to this release

[unreleased]: https://github.com/numbersprotocol/capture-lite/compare/0.89.2...HEAD
[unreleased]: https://github.com/numbersprotocol/capture-lite/compare/0.90.0...HEAD
[0.90.0]: https://github.com/numbersprotocol/capture-lite/compare/0.89.2...0.90.0
[0.89.2]: https://github.com/numbersprotocol/capture-lite/compare/0.88.8...0.89.2
[0.88.8]: https://github.com/numbersprotocol/capture-lite/compare/0.88.6...0.88.8
[0.88.6]: https://github.com/numbersprotocol/capture-lite/compare/0.87.1...0.88.6
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "io.numbersprotocol.capturelite"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 893
versionName "0.89.3"
versionCode 900
versionName "0.90.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
Expand Down
8 changes: 4 additions & 4 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,13 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 893;
CURRENT_PROJECT_VERSION = 900;
DEVELOPMENT_TEAM = G7NB5YCKAP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = G7NB5YCKAP;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.89.3;
MARKETING_VERSION = 0.90.0;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = io.numbersprotocol.capturelite;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -395,13 +395,13 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 893;
CURRENT_PROJECT_VERSION = 900;
DEVELOPMENT_TEAM = G7NB5YCKAP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = G7NB5YCKAP;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.89.3;
MARKETING_VERSION = 0.90.0;
PRODUCT_BUNDLE_IDENTIFIER = io.numbersprotocol.capturelite;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = NumbersAppDistributionV6;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "capture-lite",
"version": "0.89.3",
"version": "0.90.0",
"author": "numbersprotocol",
"homepage": "https://numbersprotocol.io/",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/app/features/home/capture-tab/capture-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export class CaptureTabComponent implements OnInit {
);

readonly captures$ = this.proofs$.pipe(
map(proofs => proofs.sort((a, b) => b.timestamp - a.timestamp))
map(proofs =>
proofs.sort((a, b) => b.uploadedAtOrTimestamp - a.uploadedAtOrTimestamp)
)
);

readonly networkConnected$ = this.networkService.connected$;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export interface DiaBackendAsset extends Tuple {
readonly caption: string;
readonly post_creation_workflow_id: string;
readonly mint_workflow_id: string;
readonly uploaded_at: string;
}

export interface OwnerAddresses extends Tuple {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class DiaBackendAssetDownloadingService {
});
proof.diaBackendAssetId = diaBackendAsset.id;
proof.caption = diaBackendAsset.caption;
proof.uploadedAt = diaBackendAsset.uploaded_at;
if (diaBackendAsset.signed_metadata) proof.setSignatureVersion();
return this.proofRepository.add(proof, OnConflictStrategy.REPLACE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class DiaBackendAssetUploadingService {
}),
map(diaBackendAsset => {
proof.diaBackendAssetId = diaBackendAsset.id;
proof.uploadedAt = diaBackendAsset.uploaded_at;
return proof;
}),
retryWhen(err$ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class DiaBackendService {
) {}

appInfo$() {
return defer(() => this.authService.getAuthHeaders()).pipe(
return defer(() => this.authService.getAuthHeadersWithApiKey()).pipe(
concatMap(headers =>
this.httpClient.get<DiaBackendAppInfo>(
`${BASE_URL}/api/v3/services/app-info/`,
Expand Down
37 changes: 37 additions & 0 deletions src/app/shared/repositories/proof/proof.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,43 @@ describe('Proof utils', () => {
const expected = `{\n "asset_mime_type": "${ASSET1_MIMETYPE}",\n "caption": "",\n "created_at": ${TIMESTAMP},\n "device_name": "${DEVICE_NAME_VALUE1}",\n "information": {\n "device.device_name": "${DEVICE_NAME_VALUE2}",\n "device.humidity": 0.8,\n "geolocation.geolocation_latitude": ${GEOLOCATION_LATITUDE2},\n "geolocation.geolocation_longitude": ${GEOLOCATION_LONGITUDE2}\n },\n "location_latitude": ${GEOLOCATION_LATITUDE1},\n "location_longitude": ${GEOLOCATION_LONGITUDE1},\n "proof_hash": "${ASSET1_SHA256SUM}",\n "recorder": "Capture",\n "spec_version": "2.0.0"\n}`;
expect(getSerializedSortedProofMetadata(ProofMetadata)).toEqual(expected);
});

describe('uploadedAtOrTimestamp', () => {
it('should return timestamp in milliseconds when uploadedAt is undefined', async () => {
proof = await Proof.from(mediaStore, ASSETS, TRUTH, SIGNATURES_VALID);
expect(proof.uploadedAtOrTimestamp).toEqual(TRUTH.timestamp);
});

it('should return uploadedAt in milliseconds when uploadedAt is defined', async () => {
const date = '2023-12-21T01:15:17Z'; // sample returned by API
const dateInMilliseconds = Date.parse(date);

proof = await Proof.from(mediaStore, ASSETS, TRUTH, SIGNATURES_VALID);
proof.uploadedAt = date;

expect(proof.uploadedAtOrTimestamp).toEqual(dateInMilliseconds);
});

it('should return timestamp in milliseconds when uploadedAt is not a valid date', async () => {
proof = await Proof.from(mediaStore, ASSETS, TRUTH, SIGNATURES_VALID);
proof.uploadedAt = 'invalid date';
expect(proof.uploadedAtOrTimestamp).toEqual(TRUTH.timestamp);
});

it('should return timestamp in milliseconds when its in seconds', async () => {
const timestamp = 1627545600; // 29th July 2021 12:00:00 GMT
const timestampInMilliseconds = timestamp * 1000;

proof = await Proof.from(
mediaStore,
ASSETS,
{ ...TRUTH, timestamp },
SIGNATURES_VALID
);

expect(proof.uploadedAtOrTimestamp).toEqual(timestampInMilliseconds);
});
});
});

const ASSET1_MIMETYPE: MimeType = 'image/png';
Expand Down
36 changes: 36 additions & 0 deletions src/app/shared/repositories/proof/proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export class Proof {
*/
caption = '';

/**
* The timestamp when the asset is uploaded to the backend, in the format "2023-12-21T01:15:17Z".
* By default, it is undefined. Once the asset is successfully uploaded, the uploadedAt property
* will be set to the timestamp provided by the backend.
*/
uploadedAt?: string = undefined;

isCollected = false;

signatures: Signatures = {};
Expand All @@ -47,6 +54,32 @@ export class Proof {
*/
cameraSource: CameraSource = CameraSource.Camera;

/**
* Used to sort the assets in the VERIFIED tab either by timestamp or uploadedAt (if available).
*/
get uploadedAtOrTimestamp() {
const MILLISECONDS_PER_SECOND = 1000;
const LENGTH_IN_MILLISECONDS = 13;

// convert timestamp to milliseconds if needed
const proofTimestampInMilliseconds =
this.timestamp.toString().length === LENGTH_IN_MILLISECONDS
? this.timestamp
: this.timestamp * MILLISECONDS_PER_SECOND;

const serverTimestampInMilliseconds = Date.parse(this.uploadedAt ?? '');
return serverTimestampInMilliseconds || proofTimestampInMilliseconds;
}

/**
* The timestamp when the proof was first created or captured. Different from uploadedAt
* The timestamp is generated using Date.now() and is represented in milliseconds.
*
* Note: After restoring or syncing with the backend assets, the timestamp will be in seconds.
* For more details, refer to https://github.com/numbersprotocol/storage-backend/issues/976
*
* Note: Milliseconds are 13 digits long, while seconds are 10 digits long.
*/
get timestamp() {
return this.truth.timestamp;
}
Expand Down Expand Up @@ -127,6 +160,7 @@ export class Proof {
proof.setIndexedAssets(indexedProofView.indexedAssets);
proof.diaBackendAssetId = indexedProofView.diaBackendAssetId;
proof.caption = indexedProofView.caption ?? '';
proof.uploadedAt = indexedProofView.uploadedAt;
proof.isCollected = indexedProofView.isCollected ?? false;
proof.signatureVersion = indexedProofView.signatureVersion;
proof.integritySha = indexedProofView.integritySha;
Expand Down Expand Up @@ -298,6 +332,7 @@ export class Proof {
signatureVersion: this.signatureVersion,
diaBackendAssetId: this.diaBackendAssetId,
caption: this.caption,
uploadedAt: this.uploadedAt,
isCollected: this.isCollected,
integritySha: this.integritySha,
cameraSource: this.cameraSource,
Expand Down Expand Up @@ -433,6 +468,7 @@ export interface IndexedProofView extends Tuple {
readonly signatureVersion?: string;
readonly diaBackendAssetId?: string;
readonly caption?: string;
readonly uploadedAt?: string;
readonly isCollected?: boolean;
readonly integritySha?: string;
readonly cameraSource: CameraSource;
Expand Down

0 comments on commit f5028f3

Please sign in to comment.