(
baseUrl: string,
oauth: { readonly authorizationEndpoint: string; readonly tokenEndpoint: string },
)
| 98 | ); |
| 99 | |
| 100 | const spec = ( |
| 101 | baseUrl: string, |
| 102 | oauth: { readonly authorizationEndpoint: string; readonly tokenEndpoint: string }, |
| 103 | ): string => |
| 104 | JSON.stringify({ |
| 105 | openapi: "3.0.3", |
| 106 | info: { title: "Scoped API", version: "1.0.0" }, |
| 107 | servers: [{ url: baseUrl }], |
| 108 | paths: { |
| 109 | "/inbox": { |
| 110 | get: { |
| 111 | operationId: "readInbox", |
| 112 | summary: "List inbox messages", |
| 113 | security: [{ oauth: ["mail.read"] }], |
| 114 | responses: { "200": { description: "messages" } }, |
| 115 | }, |
| 116 | }, |
| 117 | "/files": { |
| 118 | get: { |
| 119 | operationId: "listFiles", |
| 120 | summary: "List drive files", |
| 121 | security: [{ oauth: ["files.read"] }], |
| 122 | responses: { "200": { description: "files" } }, |
| 123 | }, |
| 124 | }, |
| 125 | "/admin": { |
| 126 | get: { |
| 127 | operationId: "adminAction", |
| 128 | summary: "An admin-only action", |
| 129 | security: [{ oauth: ["mail.read"] }], |
| 130 | responses: { "200": { description: "ok" } }, |
| 131 | }, |
| 132 | }, |
| 133 | }, |
| 134 | components: { |
| 135 | securitySchemes: { |
| 136 | oauth: { |
| 137 | type: "oauth2", |
| 138 | flows: { |
| 139 | authorizationCode: { |
| 140 | authorizationUrl: oauth.authorizationEndpoint, |
| 141 | tokenUrl: oauth.tokenEndpoint, |
| 142 | scopes: { |
| 143 | "mail.read": "Read mail", |
| 144 | "files.read": "Read files", |
| 145 | }, |
| 146 | }, |
| 147 | }, |
| 148 | }, |
| 149 | }, |
| 150 | }, |
| 151 | }); |
| 152 | |
| 153 | const invokeByAddressCode = (address: string, args: unknown) => ` |
| 154 | const segments = ${JSON.stringify(address)}.split(".").slice(1); |
no outgoing calls
no test coverage detected