Skip to content

@usine/gateway/admin

Requires the gateway’s admin token as a bearer token on every admin request; a missing or different token is answered with 401. Clients add the header themselves, for example with HttpClientRequest.bearerToken.

  • HttpApiMiddleware.ServiceClass

new AdminAuthorization(_): AdminAuthorization

Parameter Type
_ never

AdminAuthorization


The answer to an attach or a renewal: the attachment, and the caller token the Worker VM presents for it. A renewal of the same attachment id answers with the same token.

  • Schema.Class

new Attached(…args): Attached

Parameter Type
…args [props: object, options?: MakeOptions]

Attached

readonly attachment: AttachmentSummary

readonly callerToken: Redacted<string>


The attachments in force.

  • Schema.Class

new AttachmentList(…args): AttachmentList

Parameter Type
…args [props: object, options?: MakeOptions]

AttachmentList

readonly attachments: readonly AttachmentSummary[]


An attachment as the admin API reports it: everything but the token itself.

  • Schema.Class

new AttachmentSummary(…args): AttachmentSummary

Parameter Type
…args [props: object, options?: MakeOptions]

AttachmentSummary

readonly credential: "InstallationCredential" | "AnonymousCredential"

readonly expiresAt: Utc

readonly id: string & Brand<"AttachmentId">

readonly repository: string & Brand<"RepositoryName">

readonly worker: string & Brand<"WorkerName">

static fromAttachment(attachment): AttachmentSummary

Parameter Type
attachment Attachment

AttachmentSummary


What the executor attaches: one Attempt’s credential for one Worker and repository, until it expires.

  • Schema.Class

new AttachRequest(…args): AttachRequest

Parameter Type
…args [props: object, options?: MakeOptions]

AttachRequest

readonly credential: InstallationCredential | AnonymousCredential

readonly expiresAt: Utc

readonly repository: string & Brand<"RepositoryName">

readonly worker: string & Brand<"WorkerName">


The answer to a detach: whether the attachment existed.

  • Schema.Class

new Detached(…args): Detached

Parameter Type
…args [props: object, options?: MakeOptions]

Detached

readonly detached: boolean

const GatewayAdminApi: HttpApi.HttpApi<"GatewayAdminApi", HttpApiGroup.HttpApiGroup<"attachments", HttpApiEndpoint.HttpApiEndpoint<"attach", "POST", "/v1/attachments", never, never, Schema.toCodecJson<Schema.decodeTo<Schema.declareConstructor<AttachRequest, { credential: { _tag: "InstallationCredential"; token: Redacted; } | { _tag: "AnonymousCredential"; }; expiresAt: Utc; repository: string; worker: string; }, readonly [Schema.Struct<{ credential: …; expiresAt: …; repository: …; worker: …; }>], { credential: { _tag: "InstallationCredential"; token: Redacted; } | { _tag: "AnonymousCredential"; }; expiresAt: Utc; repository: string & Brand; worker: string & Brand; }>, Schema.Struct<{ credential: Schema.Union<readonly […, …]>; expiresAt: Schema.DateTimeUtc; repository: Schema.brand<Schema.String, "RepositoryName">; worker: Schema.brand<Schema.String, "WorkerName">; }>, never, never>>, never, Schema.toCodecJson<typeof Attached>, Schema.toCodecJson<Schema.decodeTo<Schema.declareConstructor<AttachmentAlreadyExpired, { _tag: "AttachmentAlreadyExpired"; expiresAt: Utc; repository: string; worker: string; }, readonly [Schema.TaggedStruct<"AttachmentAlreadyExpired", { expiresAt: …; repository: …; worker: …; }>], { _tag: "AttachmentAlreadyExpired"; expiresAt: Utc; repository: string & Brand; worker: string & Brand; }>, Schema.TaggedStruct<"AttachmentAlreadyExpired", { expiresAt: Schema.DateTimeUtc; repository: Schema.brand<Schema.String, "RepositoryName">; worker: Schema.brand<Schema.String, "WorkerName">; }>, never, never>>, AdminAuthorization, never> | HttpApiEndpoint.HttpApiEndpoint<"detach", "DELETE", "/v1/attachments/:id", Schema.toCodecStringTree<Schema.Struct<{ id: Schema.brand<Schema.String, "AttachmentId">; }>>, never, never, never, Schema.toCodecJson<typeof Detached>, never, AdminAuthorization, never> | HttpApiEndpoint.HttpApiEndpoint<"list", "GET", "/v1/attachments", never, never, never, never, Schema.toCodecJson<typeof AttachmentList>, never, AdminAuthorization, never> | HttpApiEndpoint.HttpApiEndpoint<"renew", "PUT", "/v1/attachments/:id", Schema.toCodecStringTree<Schema.Struct<{ id: Schema.brand<Schema.String, "AttachmentId">; }>>, never, Schema.toCodecJson<Schema.decodeTo<Schema.declareConstructor<AttachRequest, { credential: { _tag: "InstallationCredential"; token: Redacted; } | { _tag: "AnonymousCredential"; }; expiresAt: Utc; repository: string; worker: string; }, readonly [Schema.Struct<{ credential: …; expiresAt: …; repository: …; worker: …; }>], { credential: { _tag: "InstallationCredential"; token: Redacted; } | { _tag: "AnonymousCredential"; }; expiresAt: Utc; repository: string & Brand; worker: string & Brand; }>, Schema.Struct<{ credential: Schema.Union<readonly […, …]>; expiresAt: Schema.DateTimeUtc; repository: Schema.brand<Schema.String, "RepositoryName">; worker: Schema.brand<Schema.String, "WorkerName">; }>, never, never>>, never, Schema.toCodecJson<typeof Attached>, Schema.toCodecJson<Schema.decodeTo<Schema.declareConstructor<AttachmentAlreadyExpired, { _tag: "AttachmentAlreadyExpired"; expiresAt: Utc; repository: string; worker: string; }, readonly [Schema.TaggedStruct<…, …>], { _tag: "AttachmentAlreadyExpired"; expiresAt: Utc; repository: string & Brand; worker: string & Brand; }>, Schema.TaggedStruct<"AttachmentAlreadyExpired", { expiresAt: Schema.DateTimeUtc; repository: Schema.brand<Schema.String, "RepositoryName">; worker: Schema.brand<Schema.String, "WorkerName">; }>, never, never> | Schema.decodeTo<Schema.declareConstructor<AttachmentConflict, { _tag: "AttachmentConflict"; id: string; repository: string; worker: string; }, readonly [Schema.TaggedStruct<…, …>], { _tag: "AttachmentConflict"; id: string & Brand; repository: string & Brand; worker: string & Brand; }>, Schema.TaggedStruct<"AttachmentConflict", { id: Schema.brand<Schema.String, "AttachmentId">; repository: Schema.brand<Schema.String, "RepositoryName">; worker: Schema.brand<Schema.String, "WorkerName">; }>, never, never>>, AdminAuthorization, never>, false>>

The API the executor calls to attach a GitHub credential to a Worker VM for one repository at the start of an Attempt, renew it with the same id before the token expires, and detach it at cleanup. Attachments are in memory: after a gateway restart the executor’s next renewal stores the attachment again under its id, so the Attempt’s caller token stays valid.

Re-exports AttachmentId


Re-exports CallerToken


Re-exports GATEWAY_TOKEN_HEADER


Re-exports InstallationCredential