Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@
"configuration": {
"title": "Socket Security",
"properties": {
"socket-security.orgSlug": {
"order": 1,
"type": "string",
"scope": "window",
"description": "Socket organization slug for your API token. Select a slug accessible to the token.",
"examples": [
"acme"
]
},
"socket-security.pythonInterpreter": {
"order": 1,
"type": "string",
Expand Down
2 changes: 2 additions & 0 deletions src/api.mts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {

export type OrgInfo = {
id: string
slug: string
name: string
image: string | undefined
// The Socket API returns an open-ended plan string (opensource, team,
Expand Down Expand Up @@ -120,6 +121,7 @@ export async function getOrganizations(
const org = orgList[i]!
organizations.set(org.id, {
id: org.id,
slug: typeof org.slug === 'string' ? org.slug : '',
name: org.name ?? '',
image: org.image ?? undefined,
plan: org.plan,
Expand Down
34 changes: 34 additions & 0 deletions src/auth-context-state.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export type Listener = (ready: boolean) => void

let revision = 0
let ready = true
const listeners = new Set<Listener>()

export function beginAuthContextSync(): number {
revision += 1
ready = false
for (const listener of listeners) {
listener(false)
}
return revision
}

export function finishAuthContextSync(syncRevision: number): boolean {
if (syncRevision !== revision) {
return false
}
ready = true
for (const listener of listeners) {
listener(true)
}
return true
}

export function getAuthContextState(): { revision: number; ready: boolean } {
return { revision, ready }
}

export function onAuthContextStateChange(listener: Listener): () => void {
listeners.add(listener)
return () => listeners.delete(listener)
}
Loading
Loading