Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
icidasset committed Aug 31, 2023
1 parent a069c18 commit 7fac852
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 21 deletions.
6 changes: 2 additions & 4 deletions src/components/account/fission/implementations/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export async function did<FS>(

// DID is issuer of that username UCAN
return accountProof
? Ucan.decode(accountProof.token).payload.iss
? accountProof.issuer
: null
}

Expand All @@ -206,7 +206,7 @@ export async function fileSystemDID<FS>(

// DID is issuer of that username UCAN
return accountProof
? Ucan.decode(accountProof.token).payload.aud
? accountProof.audience
: null
}

Expand All @@ -231,8 +231,6 @@ export async function provideAuthority(
inventory
)

console.log("provideAuthority", maybeTicket)

if (!maybeTicket) return []
return [maybeTicket]
}
Expand Down
1 change: 1 addition & 0 deletions src/components/authority/browser-url/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class ProviderSession<AccountAnnex extends Account.AnnexParentType> extends Sess
const fileSystemTickets = Tickets.collectUnique(fileSystemTicketBundles.flat())

const accessKeys = fsQueries
.filter(q => Path.isPartition("private", q.path))
.map(q => this.inventory.findAccessKey(q.path, q.did))
.reduce(
(acc, a) => a ? [...acc, a] : acc,
Expand Down
19 changes: 5 additions & 14 deletions src/components/authority/browser-url/requestor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async function messageHandler(params: MessageHandlerParams) {
const msg = await decodeChannelData(params.event.data)
if (!msg) return

params.resetTimeout()
const timeoutId = params.resetTimeout()

const sessionsCache = params.sessionsCache
const sessionFromCache = sessionsCache[msg.did]
Expand All @@ -152,6 +152,7 @@ async function messageHandler(params: MessageHandlerParams) {
if (session.ended()) {
delete sessionsCache[msg.did]
params.channel.close()
clearTimeout(timeoutId)
}
}

Expand Down Expand Up @@ -224,8 +225,6 @@ class RequestorSession extends Session {

const payload = decryptJSONPayload(decryption.cipher, msg.payload)

console.log(payload)

if (payload.dismissed === true) {
this.eventEmitter.emit("request:dismissed")
return this.end
Expand All @@ -237,7 +236,9 @@ class RequestorSession extends Session {
|| !Array.isArray(payload.accountTickets)
|| !Array.isArray(payload.approved)
|| !Array.isArray(payload.fileSystemTickets)
|| !payload.accessKeys.every((p: unknown) => isString(p))
|| !payload.accessKeys.every((p: unknown) =>
isObject(p) && isString(p.did) && isString(p.key) && isString(p.path)
)
|| !payload.accountTickets.every((p: unknown) => isObject(p))
|| !payload.approved.every((p: unknown) => isString(p) || isObject(p))
|| !payload.fileSystemTickets.every((p: unknown) => isObject(p))
Expand Down Expand Up @@ -267,16 +268,6 @@ class RequestorSession extends Session {
await this.cabinet.addTickets("file_system", fileSystemTickets)
await this.cabinet.addAccessKeys(accessKeys)

console.log(
accountTickets.map((t: Ticket) => Ucan.decode(t.token))
)

console.log(
fileSystemTickets.map((t: Ticket) => Ucan.decode(t.token))
)

console.log(accessKeys)

const queries = payload.approved.map(q => Query.fromJSON(q))
this.eventEmitter.emit("request:authorised", { queries })
this.eventEmitter.emit("request:authorized", { queries })
Expand Down
2 changes: 1 addition & 1 deletion src/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Inventory {
return unwrappedPath.reduce(
(acc: null | { did: string; key: Uint8Array; path: Path.Distinctive<Path.Segments> }, _p, idx) => {
if (acc) return acc
const partialPath = Path.fromKind(pathKind, ...unwrappedPath.slice(0, idx))
const partialPath = Path.fromKind(pathKind, ...unwrappedPath.slice(0, idx + 1))
const key = this.lookupAccessKey(partialPath, did)
return key ? { did, key: key, path: partialPath } : null
},
Expand Down
2 changes: 0 additions & 2 deletions src/ticket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export async function cid(ticket: Ticket): Promise<CID> {
}

export function collectUnique(tickets: Ticket[]): Ticket[] {
console.log("collect", tickets)

return tickets.reduce((acc, ticket) => {
if (acc.tokens.includes(ticket.token)) {
return acc
Expand Down

0 comments on commit 7fac852

Please sign in to comment.