Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2cbc1b0
super basic picker with logging
Jul 5, 2022
bc51777
Adds SharedDirectoryAnnounce
Jul 6, 2022
bc6586b
Removes recording icon
Jul 6, 2022
fa09ec3
reverting config to its rightful checkin state
Jul 6, 2022
becfad3
updates storybook and storybook test snapshot
Jul 7, 2022
17408f8
Adds types for File System Access API
Jul 7, 2022
edfe30d
prettier
Jul 7, 2022
b9f0690
Adds SharedDirectoryAcknowledge, SharedDirectoryErrCode, updates some…
Jul 7, 2022
b3bf95c
Adds debug to logger
Jul 7, 2022
d69f16d
Adds SharedDirectoryInfoRequest
Jul 7, 2022
3474fed
Updates test with some ts-fu to get the maximum value of a numerical …
Jul 7, 2022
a0c6e9d
Updates babel targets to the latest 2 versions of primary browsers
Jul 13, 2022
1cd8131
Updates Adding Packages section with better instructions
Jul 14, 2022
589bc1e
Merge branch 'master' into isaiah/update-babel-build-targets
Jul 14, 2022
f2970db
super basic picker with logging
Jul 5, 2022
8150acc
Adds SharedDirectoryAnnounce
Jul 6, 2022
d3f9cac
Removes recording icon
Jul 6, 2022
9b5f4c6
updates storybook and storybook test snapshot
Jul 7, 2022
15d8343
Adds types for File System Access API
Jul 7, 2022
ca59266
prettier
Jul 7, 2022
20c14ff
Adds SharedDirectoryAcknowledge, SharedDirectoryErrCode, updates some…
Jul 7, 2022
43f921f
Adds debug to logger
Jul 7, 2022
e779785
Adds SharedDirectoryInfoRequest
Jul 7, 2022
265564f
Updates test with some ts-fu to get the maximum value of a numerical …
Jul 7, 2022
14a6166
swaps out wicg-native-file-system for apparently more up to date wicg…
Jul 12, 2022
317d0d8
adds SharedDirectoryInfoResponse and FileSystemObject to the codec
Jul 12, 2022
6c258ad
Retains existing functionality, substituting in a new sharedDirectory…
Jul 12, 2022
ece73c7
Adds untested walkPath
Jul 18, 2022
a187232
Merge branch 'master' into isaiah/sd-acknowledge
Jul 18, 2022
fe6ea5b
uses consts in decodeSharedDirectoryAcknowledge
Jul 18, 2022
7170e15
Merge branch 'isaiah/sd-acknowledge' into isaiah/sd-info-request
Jul 18, 2022
e54f251
uses consts in decodeSharedDirectoryInfoRequest
Jul 18, 2022
1c2ec0e
uses consts in decodeSharedDirectoryInfoRequest
Jul 18, 2022
d86c2ee
uses consts in decodePngFrame
Jul 18, 2022
85f87e5
uses consts in decodeStringMessage
Jul 18, 2022
f09ec07
uses consts in decodeMfaJson
Jul 18, 2022
a53d2ca
Merge branch 'master' into isaiah/sd-info-request
Jul 18, 2022
868f9d0
Adds __LAST to MessageType enum
Jul 18, 2022
6285d0e
Merge branch 'isaiah/sd-info-request' into isaiah/sd-info-response
Jul 19, 2022
634ad6a
reverting webapps.e change
Jul 19, 2022
e51e4e5
fixes broken merge
Jul 19, 2022
aea3043
creates getInfo for more efficient traversal
Jul 19, 2022
9b1e905
manually tested, cleaning up
Jul 19, 2022
ca89319
Merge branch 'master' into isaiah/sd-info-response
Jul 19, 2022
9a732a5
removing duplicate function definition
Jul 19, 2022
c318873
Adds plumbing for SharedDirectoryListRequest
Jul 19, 2022
ef35ede
adds a FileOrDirInfo type in sharedDirectoryManager and a toFso() in …
Jul 19, 2022
e7551ce
functionality is there with a Promise.all version of listContents, ho…
Jul 20, 2022
69d4b8c
non-promise.all version with better performance
Jul 20, 2022
3654f54
SharedDirectoryReadRequest
Jul 20, 2022
0cf13de
Merge branch 'master' into isaiah/sd-read-request
Jul 27, 2022
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
11 changes: 11 additions & 0 deletions packages/teleport/src/lib/tdp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export default class Client extends EventEmitterWebAuthnSender {
case MessageType.SHARED_DIRECTORY_INFO_REQUEST:
this.handleSharedDirectoryInfoRequest(buffer);
break;
case MessageType.SHARED_DIRECTORY_READ_REQUEST:
this.handleSharedDirectoryReadRequest(buffer);
break;
case MessageType.SHARED_DIRECTORY_LIST_REQUEST:
this.handleSharedDirectoryListRequest(buffer);
break;
Expand Down Expand Up @@ -250,6 +253,14 @@ export default class Client extends EventEmitterWebAuthnSender {
}
}

handleSharedDirectoryReadRequest(buffer: ArrayBuffer) {
const req = this.codec.decodeSharedDirectoryReadRequest(buffer);
// TODO(isaiah): delete debug logs
this.logger.debug('Received SharedDirectoryReadRequest:');
this.logger.debug(req);
// TODO(isaiah): here's where we'll handle the SharedDirectoryReadResponse.
}

async handleSharedDirectoryListRequest(buffer: ArrayBuffer) {
try {
const req = this.codec.decodeSharedDirectoryListRequest(buffer);
Expand Down
42 changes: 42 additions & 0 deletions packages/teleport/src/lib/tdp/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export enum MessageType {
SHARED_DIRECTORY_ACKNOWLEDGE = 12,
SHARED_DIRECTORY_INFO_REQUEST = 13,
SHARED_DIRECTORY_INFO_RESPONSE = 14,
SHARED_DIRECTORY_READ_REQUEST = 19,
SHARED_DIRECTORY_LIST_REQUEST = 25,
SHARED_DIRECTORY_LIST_RESPONSE = 26,
__LAST, // utility value
Expand Down Expand Up @@ -118,6 +119,16 @@ export type SharedDirectoryInfoResponse = {
fso: FileSystemObject;
};

// | message type (19) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte | offset uint64 | length uint32 |
export type SharedDirectoryReadRequest = {
completionId: number;
directoryId: number;
path: string;
pathLength: number;
offset: bigint;
length: number;
};

// | message type (25) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte |
export type SharedDirectoryListRequest = {
completionId: number;
Expand Down Expand Up @@ -682,6 +693,37 @@ export default class Codec {
};
}

// | message type (19) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte | offset uint64 | length uint32 |
Copy link
Copy Markdown
Contributor

@JanKaczmarkiewicz JanKaczmarkiewicz Jul 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[out of scope, discussion]
If we will add more request types I think we should create some simple utilities eg:

const sharedDirectoryReadRequestSchema = createSchema({
   completion_id: uint32,
   directory_id: uint32,
   path_length: uint32,
   path: byteArray,
   offset: uint64,
   length: uint32
});

export type SharedDirectoryReadRequest = ReturnType<typeof sharedDirectoryReadRequestSchema.tryParse>;

const data = sharedDirectoryReadRequestSchema.tryParse(buffer);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I'm understanding correctly. createSchema is returning a class which generates this decodeSharedDirectoryReadRequest function (as tryParse)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decodeSharedDirectoryReadRequest(
buffer: ArrayBuffer
): SharedDirectoryReadRequest {
const dv = new DataView(buffer);
let bufOffset = 0;
bufOffset += byteLength; // eat message type
let completionId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat completion_id
let directoryId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat directory_id
let pathLength = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat path_length
let path = this.decoder.decode(
new Uint8Array(buffer.slice(bufOffset, bufOffset + pathLength))
);
bufOffset += pathLength; // eat path
let offset = dv.getBigUint64(bufOffset);
bufOffset += uint64Length; // eat offset
let length = dv.getUint32(bufOffset);

return {
completionId,
directoryId,
pathLength,
path,
offset,
length,
};
}

// | message type (25) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte |
decodeSharedDirectoryListRequest(
buffer: ArrayBuffer
Expand Down
16 changes: 16 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10428,6 +10428,22 @@ node-gyp@8.4.1:
tar "^6.1.2"
which "^2.0.2"

node-gyp@8.4.1:
version "8.4.1"
resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-8.4.1.tgz#3d49308fc31f768180957d6b5746845fbd429937"
integrity sha512-olTJRgUtAb/hOXG0E93wZDs5YiJlgbXxTwQAFHyNlRsXQnYzUaF2aGgujZbw+hR8aF4ZG/rST57bWMWD16jr9w==
dependencies:
env-paths "^2.2.0"
glob "^7.1.4"
graceful-fs "^4.2.6"
make-fetch-happen "^9.1.0"
nopt "^5.0.0"
npmlog "^6.0.0"
rimraf "^3.0.2"
semver "^7.3.5"
tar "^6.1.2"
which "^2.0.2"

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down