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
59 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
6719855
SharedDirectoryReadResponse
Jul 21, 2022
92757b8
SharedDirectoryWriteRequest
Jul 21, 2022
11eb8ed
SharedDirectoryWriteResponse
Jul 21, 2022
b8dafbf
Adds jsdoc-style throws comments (https://jsdoc.app/tags-throws.html)…
Jul 21, 2022
eb7b04a
updates doc comments
Jul 21, 2022
9725524
adds SharedDirectoryMoveRequest
Jul 28, 2022
aa4f712
changing let to const
Jul 28, 2022
4dd63eb
Merge branch 'master' into isaiah/sd-move-request
Jul 28, 2022
3f7612e
Merge branch 'master' into isaiah/sd-move-request
Jul 28, 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
19 changes: 18 additions & 1 deletion packages/teleport/src/lib/tdp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export default class Client extends EventEmitterWebAuthnSender {
case MessageType.SHARED_DIRECTORY_WRITE_REQUEST:
this.handleSharedDirectoryWriteRequest(buffer);
break;
case MessageType.SHARED_DIRECTORY_MOVE_REQUEST:
this.handleSharedDirectoryMoveRequest(buffer);
break;
case MessageType.SHARED_DIRECTORY_LIST_REQUEST:
this.handleSharedDirectoryListRequest(buffer);
break;
Expand Down Expand Up @@ -301,6 +304,14 @@ export default class Client extends EventEmitterWebAuthnSender {
}
}

handleSharedDirectoryMoveRequest(buffer: ArrayBuffer) {
const req = this.codec.decodeSharedDirectoryMoveRequest(buffer);
// TODO(isaiah): delete debug logs
this.logger.debug('Received SharedDirectoryMoveRequest:');
this.logger.debug(req);
// TODO(isaiah): here's where we'll respond with a SharedDirectoryMoveResponse
}

async handleSharedDirectoryListRequest(buffer: ArrayBuffer) {
try {
const req = this.codec.decodeSharedDirectoryListRequest(buffer);
Expand Down Expand Up @@ -388,13 +399,19 @@ export default class Client extends EventEmitterWebAuthnSender {
}

sendSharedDirectoryAnnounce() {
let name: string;
try {
name = this.sdManager.getName();
} catch (e) {
this.handleError(e);
}
this.send(
this.codec.encodeSharedDirectoryAnnounce({
completionId: 0, // This is always the first request.
// Hardcode directoryId for now since we only support sharing 1 directory.
// We're using 2 because the smartcard device is hardcoded to 1 in the backend.
directoryId: 2,
name: this.sdManager.getName(),
name,
})
);
}
Expand Down
88 changes: 65 additions & 23 deletions packages/teleport/src/lib/tdp/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export enum MessageType {
SHARED_DIRECTORY_READ_RESPONSE = 20,
SHARED_DIRECTORY_WRITE_REQUEST = 21,
SHARED_DIRECTORY_WRITE_RESPONSE = 22,
SHARED_DIRECTORY_MOVE_REQUEST = 23,
SHARED_DIRECTORY_LIST_REQUEST = 25,
SHARED_DIRECTORY_LIST_RESPONSE = 26,
__LAST, // utility value
Expand Down Expand Up @@ -157,6 +158,16 @@ export type SharedDirectoryWriteResponse = {
bytesWritten: number;
};

// | message type (23) | completion_id uint32 | directory_id uint32 | original_path_length uint32 | original_path []byte | new_path_length uint32 | new_path []byte |
export type SharedDirectoryMoveRequest = {
completionId: number;
directoryId: number;
originalPathLength: number;
originalPath: string;
newPathLength: number;
newPath: string;
};

// | message type (25) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte |
export type SharedDirectoryListRequest = {
completionId: number;
Expand Down Expand Up @@ -677,7 +688,7 @@ export default class Codec {
// decodeMfaChallenge decodes a raw tdp MFA challenge message and returns it as a string (of a json).
// | message type (10) | mfa_type byte | message_length uint32 | json []byte
decodeMfaJson(buffer: ArrayBuffer): MfaJson {
let dv = new DataView(buffer);
const dv = new DataView(buffer);
let offset = 0;
offset += byteLength; // eat message type
const mfaType = String.fromCharCode(dv.getUint8(offset));
Expand Down Expand Up @@ -771,19 +782,19 @@ export default class Codec {
const dv = new DataView(buffer);
let bufOffset = 0;
bufOffset += byteLength; // eat message type
let completionId = dv.getUint32(bufOffset);
const completionId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat completion_id
let directoryId = dv.getUint32(bufOffset);
const directoryId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat directory_id
let pathLength = dv.getUint32(bufOffset);
const pathLength = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat path_length
let path = this.decoder.decode(
const path = this.decoder.decode(
new Uint8Array(buffer.slice(bufOffset, bufOffset + pathLength))
);
bufOffset += pathLength; // eat path
let offset = dv.getBigUint64(bufOffset);
const offset = dv.getBigUint64(bufOffset);
bufOffset += uint64Length; // eat offset
let length = dv.getUint32(bufOffset);
const length = dv.getUint32(bufOffset);

return {
completionId,
Expand All @@ -799,24 +810,23 @@ export default class Codec {
decodeSharedDirectoryWriteRequest(
buffer: ArrayBuffer
): SharedDirectoryWriteRequest {
let dv = new DataView(buffer);
let bufOffset = byteLength;

let completionId = dv.getUint32(bufOffset);
bufOffset += uint32Length;
let directoryId = dv.getUint32(bufOffset);
bufOffset += uint32Length;
let offset = dv.getBigUint64(bufOffset);
bufOffset += uint64Length;
let pathLength = dv.getUint32(bufOffset);
bufOffset += uint32Length;
let path = this.decoder.decode(
const dv = new DataView(buffer);
let bufOffset = byteLength; // eat message type
const completionId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat completion_id
const directoryId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat directory_id
const offset = dv.getBigUint64(bufOffset);
bufOffset += uint64Length; // eat offset
const pathLength = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat path_length
const path = this.decoder.decode(
new Uint8Array(buffer.slice(bufOffset, bufOffset + pathLength))
);
bufOffset += pathLength;
let writeDataLength = dv.getUint32(bufOffset);
bufOffset += uint32Length;
let writeData = new Uint8Array(
bufOffset += pathLength; // eat path
const writeDataLength = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat write_data_length
const writeData = new Uint8Array(
buffer.slice(bufOffset, bufOffset + writeDataLength)
);

Expand All @@ -830,6 +840,38 @@ export default class Codec {
};
}

// | message type (23) | completion_id uint32 | directory_id uint32 | original_path_length uint32 | original_path []byte | new_path_length uint32 | new_path []byte |
decodeSharedDirectoryMoveRequest(
buffer: ArrayBuffer
): SharedDirectoryMoveRequest {
const dv = new DataView(buffer);
let bufOffset = byteLength; // eat message type
const completionId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat completion_id
const directoryId = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat directory_id
const originalPathLength = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat original_path_length
const originalPath = this.decoder.decode(
new Uint8Array(buffer.slice(bufOffset, bufOffset + originalPathLength))
);
bufOffset += originalPathLength; // eat original_path
const newPathLength = dv.getUint32(bufOffset);
bufOffset += uint32Length; // eat new_path_length
const newPath = this.decoder.decode(
new Uint8Array(buffer.slice(bufOffset, bufOffset + newPathLength))
);

return {
completionId,
directoryId,
originalPathLength,
originalPath,
newPathLength,
newPath,
};
}

// | message type (25) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte |
decodeSharedDirectoryListRequest(
buffer: ArrayBuffer
Expand Down
16 changes: 0 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10412,22 +10412,6 @@ 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