-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: e2e api #102
feat: e2e api #102
Conversation
) | ||
class ExtensionDappSecurityContext extends DappSecurityContext { | ||
constructor(private extensionId: string) { | ||
super(extensionId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this will cause problem for allowed the storage key length. can you check what is the limit for that? Maybe would be better, if we transform the ID here to some prefixed and trimmed ID
|
||
this.securityContexts[sessionId] = new DappSecurityContext(tabId, frameId, frameContentRoot, originContentRoot) | ||
if (this.isSenderExtension(sender)) { | ||
context = new ExtensionDappSecurityContext(String(sessionId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the sessionId
is the extension ID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm telling you because the ExtensionDappSecurityContext
has extensionId
parameter naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context = new ExtensionDappSecurityContext(String(sessionId)) | |
context = new ExtensionDappSecurityContext(sessionId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this sessionId/extensionId is not needed at all.
action: A | ||
sessionId: string | ||
parameters: P | ||
eventId?: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make it required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So overall I think then ExtensionDappSecurityContext
does not need to extend DappSecurityContext
because in this form as you modified it only handles storage that external extensions do not use. Can we split then DappSecurityContext
into a new abstract class that defines isValid
method?
The storage related methods of DappSessionManager
could throw error if it wants to use storage actions with extension context or something similar like this.
OK. Then to remove the |
now the context only relates to handling storage space, but later it also could track requests and limiting the allowed usage towards the Bee node or pair different API authorization tokens to different contexts. the Extension(s) also need security context, but for now it only has |
Can we revive this? Maybe it can be merged once the linter issues are solved. WDYT @nugaon @tomicvladan ? |
Hey @vojtechsimetka , now the linter error is fixed and I think it can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had an additional comment about the e2e api, but I sort of understand the consideration because of single source of truth concern.
But my other comment regarding to the extension context is really important, please do something with that before merge.
private handleBzzLinkProtocolToFakeUrl(request: RequestType): string | null { | ||
const { | ||
sessionId, | ||
parameters: { url, newPage }, | ||
} = request as BzzLinkProtocolToFakeUrlRequest | ||
|
||
return bzzProtocolToFakeUrl(url, sessionId, newPage) | ||
} | ||
|
||
private handleBzzLinkUrlToFakeUrl(request: RequestType): string | null { | ||
const { | ||
sessionId, | ||
parameters: { bzzLinkUrl, newPage }, | ||
} = request as BzzLinkLinkUrlToFakeUrlRequest | ||
|
||
return bzzProtocolToFakeUrl(bzzLinkUrl, sessionId, newPage) | ||
} | ||
|
||
private handleBzzUrlToFakeUrl(request: RequestType): string | null { | ||
const { | ||
sessionId, | ||
parameters: { url, newPage }, | ||
} = request as BzzLinkUrlToFakeUrlRequest | ||
|
||
return bzzProtocolToFakeUrl(url, sessionId, newPage) | ||
} | ||
|
||
private handleWeb2FakeBeeApiAddress(request: RequestType): string { | ||
const { sessionId } = request | ||
|
||
return appendSwarmSessionIdToUrl(fakeUrl.beeApiAddress, sessionId) | ||
} | ||
|
||
private handleWeb2FakeBzzAddress(request: RequestType): string { | ||
const { | ||
sessionId, | ||
parameters: { reference }, | ||
} = request as Web2HelprFakeBzzAddressRequest | ||
|
||
return appendSwarmSessionIdToUrl(`${fakeUrl.bzzProtocol}/${reference}`, sessionId) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic could be completely on the other extension's side and you could save the async calls.
@@ -56,19 +85,45 @@ class DappSecurityContext { | |||
} | |||
} | |||
|
|||
class ExtensionDappSecurityContext extends DappSecurityContext { | |||
constructor() { | |||
super('extension') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will mix two different and independent extension's context.
it should be distinguished by their extension id or only the blossom extension should be able to call the swarm-extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ExtensionDappSecurityContext
is actually stateless. If in the future we want to store some state, then we can use extension ID to distinguish different extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be resolved later: #132
Extension to extension API (#76)