@shware/http 1.1.13 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/__tests__/index.test.cjs +0 -27
- package/dist/__tests__/index.test.cjs.map +0 -1
- package/dist/__tests__/index.test.d.cts +0 -2
- package/dist/__tests__/index.test.d.ts +0 -2
- package/dist/__tests__/index.test.mjs +0 -25
- package/dist/__tests__/index.test.mjs.map +0 -1
- package/dist/cache/index.cjs +0 -32
- package/dist/cache/index.cjs.map +0 -1
- package/dist/cache/index.d.cts +0 -9
- package/dist/cache/index.d.ts +0 -9
- package/dist/cache/index.mjs +0 -7
- package/dist/cache/index.mjs.map +0 -1
- package/dist/error/detail.cjs +0 -93
- package/dist/error/detail.cjs.map +0 -1
- package/dist/error/detail.d.cts +0 -99
- package/dist/error/detail.d.ts +0 -99
- package/dist/error/detail.mjs +0 -67
- package/dist/error/detail.mjs.map +0 -1
- package/dist/error/i18n/en-us.cjs +0 -31
- package/dist/error/i18n/en-us.cjs.map +0 -1
- package/dist/error/i18n/en-us.d.cts +0 -3
- package/dist/error/i18n/en-us.d.ts +0 -3
- package/dist/error/i18n/en-us.mjs +0 -6
- package/dist/error/i18n/en-us.mjs.map +0 -1
- package/dist/error/index.cjs +0 -63
- package/dist/error/index.cjs.map +0 -1
- package/dist/error/index.d.cts +0 -19
- package/dist/error/index.d.ts +0 -19
- package/dist/error/index.mjs +0 -35
- package/dist/error/index.mjs.map +0 -1
- package/dist/error/parse.cjs +0 -52
- package/dist/error/parse.cjs.map +0 -1
- package/dist/error/parse.d.cts +0 -16
- package/dist/error/parse.d.ts +0 -16
- package/dist/error/parse.mjs +0 -27
- package/dist/error/parse.mjs.map +0 -1
- package/dist/error/reason.cjs +0 -19
- package/dist/error/reason.cjs.map +0 -1
- package/dist/error/reason.d.cts +0 -66
- package/dist/error/reason.d.ts +0 -66
- package/dist/error/reason.mjs +0 -1
- package/dist/error/reason.mjs.map +0 -1
- package/dist/error/status.cjs +0 -266
- package/dist/error/status.cjs.map +0 -1
- package/dist/error/status.d.cts +0 -69
- package/dist/error/status.d.ts +0 -69
- package/dist/error/status.mjs +0 -237
- package/dist/error/status.mjs.map +0 -1
- package/dist/google-one-tap/index.cjs +0 -51
- package/dist/google-one-tap/index.cjs.map +0 -1
- package/dist/google-one-tap/index.d.cts +0 -17
- package/dist/google-one-tap/index.d.ts +0 -17
- package/dist/google-one-tap/index.mjs +0 -26
- package/dist/google-one-tap/index.mjs.map +0 -1
- package/dist/google-one-tap/types.cjs +0 -19
- package/dist/google-one-tap/types.cjs.map +0 -1
- package/dist/google-one-tap/types.d.cts +0 -155
- package/dist/google-one-tap/types.d.ts +0 -155
- package/dist/google-one-tap/types.mjs +0 -1
- package/dist/google-one-tap/types.mjs.map +0 -1
- package/dist/hono/__tests__/authorizer.test.cjs +0 -483
- package/dist/hono/__tests__/authorizer.test.cjs.map +0 -1
- package/dist/hono/__tests__/authorizer.test.d.cts +0 -2
- package/dist/hono/__tests__/authorizer.test.d.ts +0 -2
- package/dist/hono/__tests__/authorizer.test.mjs +0 -481
- package/dist/hono/__tests__/authorizer.test.mjs.map +0 -1
- package/dist/hono/__tests__/csrf.test.cjs +0 -162
- package/dist/hono/__tests__/csrf.test.cjs.map +0 -1
- package/dist/hono/__tests__/csrf.test.d.cts +0 -2
- package/dist/hono/__tests__/csrf.test.d.ts +0 -2
- package/dist/hono/__tests__/csrf.test.mjs +0 -160
- package/dist/hono/__tests__/csrf.test.mjs.map +0 -1
- package/dist/hono/authorizer.cjs +0 -99
- package/dist/hono/authorizer.cjs.map +0 -1
- package/dist/hono/authorizer.d.cts +0 -25
- package/dist/hono/authorizer.d.ts +0 -25
- package/dist/hono/authorizer.mjs +0 -73
- package/dist/hono/authorizer.mjs.map +0 -1
- package/dist/hono/csrf.cjs +0 -93
- package/dist/hono/csrf.cjs.map +0 -1
- package/dist/hono/csrf.d.cts +0 -65
- package/dist/hono/csrf.d.ts +0 -65
- package/dist/hono/csrf.mjs +0 -68
- package/dist/hono/csrf.mjs.map +0 -1
- package/dist/hono/geolocation.cjs +0 -75
- package/dist/hono/geolocation.cjs.map +0 -1
- package/dist/hono/geolocation.d.cts +0 -17
- package/dist/hono/geolocation.d.ts +0 -17
- package/dist/hono/geolocation.mjs +0 -50
- package/dist/hono/geolocation.mjs.map +0 -1
- package/dist/hono/handler.cjs +0 -68
- package/dist/hono/handler.cjs.map +0 -1
- package/dist/hono/handler.d.cts +0 -13
- package/dist/hono/handler.d.ts +0 -13
- package/dist/hono/handler.mjs +0 -42
- package/dist/hono/handler.mjs.map +0 -1
- package/dist/hono/index.cjs +0 -47
- package/dist/hono/index.cjs.map +0 -1
- package/dist/hono/index.d.cts +0 -12
- package/dist/hono/index.d.ts +0 -12
- package/dist/hono/index.mjs +0 -16
- package/dist/hono/index.mjs.map +0 -1
- package/dist/hono/validator.cjs +0 -64
- package/dist/hono/validator.cjs.map +0 -1
- package/dist/hono/validator.d.cts +0 -28
- package/dist/hono/validator.d.ts +0 -28
- package/dist/hono/validator.mjs +0 -38
- package/dist/hono/validator.mjs.map +0 -1
- package/dist/index-BnPgRQDl.d.cts +0 -129
- package/dist/index-BnPgRQDl.d.ts +0 -129
- package/dist/index.cjs +0 -91
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -18
- package/dist/index.d.ts +0 -18
- package/dist/index.mjs +0 -46
- package/dist/index.mjs.map +0 -1
- package/dist/iso/iso_3601_1.cjs +0 -292
- package/dist/iso/iso_3601_1.cjs.map +0 -1
- package/dist/iso/iso_3601_1.d.cts +0 -9
- package/dist/iso/iso_3601_1.d.ts +0 -9
- package/dist/iso/iso_3601_1.mjs +0 -267
- package/dist/iso/iso_3601_1.mjs.map +0 -1
- package/dist/max-length/index.cjs +0 -94
- package/dist/max-length/index.cjs.map +0 -1
- package/dist/max-length/index.d.cts +0 -1
- package/dist/max-length/index.d.ts +0 -1
- package/dist/max-length/index.mjs +0 -48
- package/dist/max-length/index.mjs.map +0 -1
- package/dist/message.cjs +0 -32
- package/dist/message.cjs.map +0 -1
- package/dist/message.d.cts +0 -3
- package/dist/message.d.ts +0 -3
- package/dist/message.mjs +0 -7
- package/dist/message.mjs.map +0 -1
- package/dist/polyfills/index.cjs +0 -7
- package/dist/polyfills/index.cjs.map +0 -1
- package/dist/polyfills/index.d.cts +0 -2
- package/dist/polyfills/index.d.ts +0 -2
- package/dist/polyfills/index.mjs +0 -5
- package/dist/polyfills/index.mjs.map +0 -1
- package/dist/response.cjs +0 -73
- package/dist/response.cjs.map +0 -1
- package/dist/response.d.cts +0 -65
- package/dist/response.d.ts +0 -65
- package/dist/response.mjs +0 -44
- package/dist/response.mjs.map +0 -1
- package/dist/snowflake.cjs +0 -75
- package/dist/snowflake.cjs.map +0 -1
- package/dist/snowflake.d.cts +0 -29
- package/dist/snowflake.d.ts +0 -29
- package/dist/snowflake.mjs +0 -49
- package/dist/snowflake.mjs.map +0 -1
- package/dist/utils/__tests__/ip.test.cjs +0 -38
- package/dist/utils/__tests__/ip.test.cjs.map +0 -1
- package/dist/utils/__tests__/ip.test.d.cts +0 -2
- package/dist/utils/__tests__/ip.test.d.ts +0 -2
- package/dist/utils/__tests__/ip.test.mjs +0 -36
- package/dist/utils/__tests__/ip.test.mjs.map +0 -1
- package/dist/utils/invariant.cjs +0 -37
- package/dist/utils/invariant.cjs.map +0 -1
- package/dist/utils/invariant.d.cts +0 -3
- package/dist/utils/invariant.d.ts +0 -3
- package/dist/utils/invariant.mjs +0 -12
- package/dist/utils/invariant.mjs.map +0 -1
- package/dist/utils/ip.cjs +0 -53
- package/dist/utils/ip.cjs.map +0 -1
- package/dist/utils/ip.d.cts +0 -3
- package/dist/utils/ip.d.ts +0 -3
- package/dist/utils/ip.mjs +0 -28
- package/dist/utils/ip.mjs.map +0 -1
- package/dist/utils/promise.cjs +0 -47
- package/dist/utils/promise.cjs.map +0 -1
- package/dist/utils/promise.d.cts +0 -3
- package/dist/utils/promise.d.ts +0 -3
- package/dist/utils/promise.mjs +0 -22
- package/dist/utils/promise.mjs.map +0 -1
- package/dist/utils/string.cjs +0 -33
- package/dist/utils/string.cjs.map +0 -1
- package/dist/utils/string.d.cts +0 -6
- package/dist/utils/string.d.ts +0 -6
- package/dist/utils/string.mjs +0 -8
- package/dist/utils/string.mjs.map +0 -1
- package/dist/utils/timing.cjs +0 -74
- package/dist/utils/timing.cjs.map +0 -1
- package/dist/utils/timing.d.cts +0 -13
- package/dist/utils/timing.d.ts +0 -13
- package/dist/utils/timing.mjs +0 -49
- package/dist/utils/timing.mjs.map +0 -1
- package/dist/utils/token-bucket.cjs +0 -73
- package/dist/utils/token-bucket.cjs.map +0 -1
- package/dist/utils/token-bucket.d.cts +0 -20
- package/dist/utils/token-bucket.d.ts +0 -20
- package/dist/utils/token-bucket.mjs +0 -48
- package/dist/utils/token-bucket.mjs.map +0 -1
- package/dist/vaild.cjs +0 -51
- package/dist/vaild.cjs.map +0 -1
- package/dist/vaild.d.cts +0 -13
- package/dist/vaild.d.ts +0 -13
- package/dist/vaild.mjs +0 -26
- package/dist/vaild.mjs.map +0 -1
- package/dist/webhook/index.cjs +0 -77
- package/dist/webhook/index.cjs.map +0 -1
- package/dist/webhook/index.d.cts +0 -10
- package/dist/webhook/index.d.ts +0 -10
- package/dist/webhook/index.mjs +0 -52
- package/dist/webhook/index.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was cancelled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error?.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n if ((Error as any).captureStackTrace) {\n (Error as any).captureStackTrace(this, StatusError);\n }\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA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c,CAAC,YAAqB,WAAW,GAAG,eAAe,OAAO;AAAA,EAC/E,OAAO,WAAW,CAAC,YAAqB,WAAW,GAAG,aAAa,OAAO;AAAA,EAC1E,OAAO,mBAAmB,CAAC,YAAqB,WAAW,GAAG,sBAAsB,OAAO;AAC7F;","names":[]}
|
package/dist/error/status.d.cts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Detail, Details } from './detail.cjs';
|
|
2
|
-
import './reason.cjs';
|
|
3
|
-
|
|
4
|
-
declare const Code: {
|
|
5
|
-
readonly OK: 200;
|
|
6
|
-
readonly CANCELLED: 499;
|
|
7
|
-
readonly UNKNOWN: 500;
|
|
8
|
-
readonly INVALID_ARGUMENT: 400;
|
|
9
|
-
readonly DEADLINE_EXCEEDED: 504;
|
|
10
|
-
readonly NOT_FOUND: 404;
|
|
11
|
-
readonly ALREADY_EXISTS: 409;
|
|
12
|
-
readonly PERMISSION_DENIED: 403;
|
|
13
|
-
readonly RESOURCE_EXHAUSTED: 429;
|
|
14
|
-
readonly FAILED_PRECONDITION: 400;
|
|
15
|
-
readonly ABORTED: 409;
|
|
16
|
-
readonly OUT_OF_RANGE: 400;
|
|
17
|
-
readonly UNIMPLEMENTED: 501;
|
|
18
|
-
readonly INTERNAL: 500;
|
|
19
|
-
readonly UNAVAILABLE: 503;
|
|
20
|
-
readonly DATA_LOSS: 500;
|
|
21
|
-
readonly UNAUTHENTICATED: 401;
|
|
22
|
-
readonly METHOD_NOT_ALLOWED: 405;
|
|
23
|
-
};
|
|
24
|
-
declare const DEFAULT_MESSAGES: Record<keyof typeof Code, string>;
|
|
25
|
-
interface ErrorBody {
|
|
26
|
-
error: {
|
|
27
|
-
code: number;
|
|
28
|
-
status: keyof typeof Code;
|
|
29
|
-
message: string;
|
|
30
|
-
details: Detail[];
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
declare class StatusError extends Error {
|
|
34
|
-
readonly status: number;
|
|
35
|
-
readonly body?: ErrorBody;
|
|
36
|
-
constructor(status: number, body?: ErrorBody);
|
|
37
|
-
}
|
|
38
|
-
declare class StatusCode {
|
|
39
|
-
code: keyof typeof Code;
|
|
40
|
-
message?: string;
|
|
41
|
-
private constructor();
|
|
42
|
-
static of(code: keyof typeof Code, message?: string): StatusCode;
|
|
43
|
-
body(details?: Details): ErrorBody;
|
|
44
|
-
error(details?: Details): Error;
|
|
45
|
-
response(details?: Details): Response;
|
|
46
|
-
}
|
|
47
|
-
declare class Status {
|
|
48
|
-
static adapter?: (status: number, response: ErrorBody) => Error;
|
|
49
|
-
static ok: (message?: string) => StatusCode;
|
|
50
|
-
static cancelled: (message?: string) => StatusCode;
|
|
51
|
-
static unknown: (message?: string) => StatusCode;
|
|
52
|
-
static invalidArgument: (message?: string) => StatusCode;
|
|
53
|
-
static deadlineExceeded: (message?: string) => StatusCode;
|
|
54
|
-
static notFound: (message?: string) => StatusCode;
|
|
55
|
-
static alreadyExists: (message?: string) => StatusCode;
|
|
56
|
-
static permissionDenied: (message?: string) => StatusCode;
|
|
57
|
-
static unauthorized: (message?: string) => StatusCode;
|
|
58
|
-
static resourceExhausted: (message?: string) => StatusCode;
|
|
59
|
-
static failedPrecondition: (message?: string) => StatusCode;
|
|
60
|
-
static aborted: (message?: string) => StatusCode;
|
|
61
|
-
static outOfRange: (message?: string) => StatusCode;
|
|
62
|
-
static unimplemented: (message?: string) => StatusCode;
|
|
63
|
-
static internal: (message?: string) => StatusCode;
|
|
64
|
-
static unavailable: (message?: string) => StatusCode;
|
|
65
|
-
static dataLoss: (message?: string) => StatusCode;
|
|
66
|
-
static methodNotAllowed: (message?: string) => StatusCode;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { Code, DEFAULT_MESSAGES, type ErrorBody, Status, StatusCode, StatusError };
|
package/dist/error/status.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Detail, Details } from './detail.js';
|
|
2
|
-
import './reason.js';
|
|
3
|
-
|
|
4
|
-
declare const Code: {
|
|
5
|
-
readonly OK: 200;
|
|
6
|
-
readonly CANCELLED: 499;
|
|
7
|
-
readonly UNKNOWN: 500;
|
|
8
|
-
readonly INVALID_ARGUMENT: 400;
|
|
9
|
-
readonly DEADLINE_EXCEEDED: 504;
|
|
10
|
-
readonly NOT_FOUND: 404;
|
|
11
|
-
readonly ALREADY_EXISTS: 409;
|
|
12
|
-
readonly PERMISSION_DENIED: 403;
|
|
13
|
-
readonly RESOURCE_EXHAUSTED: 429;
|
|
14
|
-
readonly FAILED_PRECONDITION: 400;
|
|
15
|
-
readonly ABORTED: 409;
|
|
16
|
-
readonly OUT_OF_RANGE: 400;
|
|
17
|
-
readonly UNIMPLEMENTED: 501;
|
|
18
|
-
readonly INTERNAL: 500;
|
|
19
|
-
readonly UNAVAILABLE: 503;
|
|
20
|
-
readonly DATA_LOSS: 500;
|
|
21
|
-
readonly UNAUTHENTICATED: 401;
|
|
22
|
-
readonly METHOD_NOT_ALLOWED: 405;
|
|
23
|
-
};
|
|
24
|
-
declare const DEFAULT_MESSAGES: Record<keyof typeof Code, string>;
|
|
25
|
-
interface ErrorBody {
|
|
26
|
-
error: {
|
|
27
|
-
code: number;
|
|
28
|
-
status: keyof typeof Code;
|
|
29
|
-
message: string;
|
|
30
|
-
details: Detail[];
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
declare class StatusError extends Error {
|
|
34
|
-
readonly status: number;
|
|
35
|
-
readonly body?: ErrorBody;
|
|
36
|
-
constructor(status: number, body?: ErrorBody);
|
|
37
|
-
}
|
|
38
|
-
declare class StatusCode {
|
|
39
|
-
code: keyof typeof Code;
|
|
40
|
-
message?: string;
|
|
41
|
-
private constructor();
|
|
42
|
-
static of(code: keyof typeof Code, message?: string): StatusCode;
|
|
43
|
-
body(details?: Details): ErrorBody;
|
|
44
|
-
error(details?: Details): Error;
|
|
45
|
-
response(details?: Details): Response;
|
|
46
|
-
}
|
|
47
|
-
declare class Status {
|
|
48
|
-
static adapter?: (status: number, response: ErrorBody) => Error;
|
|
49
|
-
static ok: (message?: string) => StatusCode;
|
|
50
|
-
static cancelled: (message?: string) => StatusCode;
|
|
51
|
-
static unknown: (message?: string) => StatusCode;
|
|
52
|
-
static invalidArgument: (message?: string) => StatusCode;
|
|
53
|
-
static deadlineExceeded: (message?: string) => StatusCode;
|
|
54
|
-
static notFound: (message?: string) => StatusCode;
|
|
55
|
-
static alreadyExists: (message?: string) => StatusCode;
|
|
56
|
-
static permissionDenied: (message?: string) => StatusCode;
|
|
57
|
-
static unauthorized: (message?: string) => StatusCode;
|
|
58
|
-
static resourceExhausted: (message?: string) => StatusCode;
|
|
59
|
-
static failedPrecondition: (message?: string) => StatusCode;
|
|
60
|
-
static aborted: (message?: string) => StatusCode;
|
|
61
|
-
static outOfRange: (message?: string) => StatusCode;
|
|
62
|
-
static unimplemented: (message?: string) => StatusCode;
|
|
63
|
-
static internal: (message?: string) => StatusCode;
|
|
64
|
-
static unavailable: (message?: string) => StatusCode;
|
|
65
|
-
static dataLoss: (message?: string) => StatusCode;
|
|
66
|
-
static methodNotAllowed: (message?: string) => StatusCode;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { Code, DEFAULT_MESSAGES, type ErrorBody, Status, StatusCode, StatusError };
|
package/dist/error/status.mjs
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
// src/error/status.ts
|
|
2
|
-
var Code = {
|
|
3
|
-
// Not an error; returned on success
|
|
4
|
-
//
|
|
5
|
-
// HTTP Mapping: 200 OK
|
|
6
|
-
OK: 200,
|
|
7
|
-
// The operation was cancelled, typically by the caller.
|
|
8
|
-
//
|
|
9
|
-
// HTTP Mapping: 499 Client Closed Request
|
|
10
|
-
CANCELLED: 499,
|
|
11
|
-
// Unknown error. For example, this error may be returned when
|
|
12
|
-
// a `Status` value received from another address space belongs to
|
|
13
|
-
// an error space that is not known in this address space. Also,
|
|
14
|
-
// errors raised by APIs that do not return enough error information
|
|
15
|
-
// may be converted to this error.
|
|
16
|
-
//
|
|
17
|
-
// HTTP Mapping: 500 Internal Server Error
|
|
18
|
-
UNKNOWN: 500,
|
|
19
|
-
// The client specified an invalid argument. Note that this differs
|
|
20
|
-
// from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
|
|
21
|
-
// that are problematic regardless of the state of the system
|
|
22
|
-
// (e.g., a malformed file name).
|
|
23
|
-
//
|
|
24
|
-
// HTTP Mapping: 400 Bad Request
|
|
25
|
-
INVALID_ARGUMENT: 400,
|
|
26
|
-
// The deadline expired before the operation could complete. For operations
|
|
27
|
-
// that change the state of the system, this error may be returned
|
|
28
|
-
// even if the operation has completed successfully. For example, a
|
|
29
|
-
// successful response from a server could have been delayed long
|
|
30
|
-
// enough for the deadline to expire.
|
|
31
|
-
//
|
|
32
|
-
// HTTP Mapping: 504 Gateway Timeout
|
|
33
|
-
DEADLINE_EXCEEDED: 504,
|
|
34
|
-
// Some requested entity (e.g., file or directory) was not found.
|
|
35
|
-
//
|
|
36
|
-
// Note to server developers: if a request is denied for an entire class
|
|
37
|
-
// of users, such as gradual feature rollout or undocumented whitelist,
|
|
38
|
-
// `NOT_FOUND` may be used. If a request is denied for some users within
|
|
39
|
-
// a class of users, such as user-based access control, `PERMISSION_DENIED`
|
|
40
|
-
// must be used.
|
|
41
|
-
//
|
|
42
|
-
// HTTP Mapping: 404 Not Found
|
|
43
|
-
NOT_FOUND: 404,
|
|
44
|
-
// The entity that a client attempted to create (e.g., file or directory)
|
|
45
|
-
// already exists.
|
|
46
|
-
//
|
|
47
|
-
// HTTP Mapping: 409 Conflict
|
|
48
|
-
ALREADY_EXISTS: 409,
|
|
49
|
-
// The caller does not have permission to execute the specified
|
|
50
|
-
// operation. `PERMISSION_DENIED` must not be used for rejections
|
|
51
|
-
// caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
|
|
52
|
-
// instead for those errors). `PERMISSION_DENIED` must not be
|
|
53
|
-
// used if the caller can not be identified (use `UNAUTHENTICATED`
|
|
54
|
-
// instead for those errors). This error code does not imply the
|
|
55
|
-
// request is valid or the requested entity exists or satisfies
|
|
56
|
-
// other pre-conditions.
|
|
57
|
-
//
|
|
58
|
-
// HTTP Mapping: 403 Forbidden
|
|
59
|
-
PERMISSION_DENIED: 403,
|
|
60
|
-
// Some resource has been exhausted, perhaps a per-user quota, or
|
|
61
|
-
// perhaps the entire file system is out of space.
|
|
62
|
-
//
|
|
63
|
-
// HTTP Mapping: 429 Too Many Requests
|
|
64
|
-
RESOURCE_EXHAUSTED: 429,
|
|
65
|
-
// The operation was rejected because the system is not in a state
|
|
66
|
-
// required for the operation's execution. For example, the directory
|
|
67
|
-
// to be deleted is non-empty, a rmdir operation is applied to
|
|
68
|
-
// a non-directory, etc.
|
|
69
|
-
//
|
|
70
|
-
// Service implementors can use the following guidelines to decide
|
|
71
|
-
// between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
|
|
72
|
-
// (a) Use `UNAVAILABLE` if the client can retry just the failing call.
|
|
73
|
-
// (b) Use `ABORTED` if the client should retry at a higher level
|
|
74
|
-
// (e.g., when a client-specified test-and-set fails, indicating the
|
|
75
|
-
// client should restart a read-modify-write sequence).
|
|
76
|
-
// (c) Use `FAILED_PRECONDITION` if the client should not retry until
|
|
77
|
-
// the system state has been explicitly fixed. E.g., if a "rmdir"
|
|
78
|
-
// fails because the directory is non-empty, `FAILED_PRECONDITION`
|
|
79
|
-
// should be returned since the client should not retry unless
|
|
80
|
-
// the files are deleted from the directory.
|
|
81
|
-
//
|
|
82
|
-
// HTTP Mapping: 400 Bad Request
|
|
83
|
-
FAILED_PRECONDITION: 400,
|
|
84
|
-
// The operation was aborted, typically due to a concurrency issue such as
|
|
85
|
-
// a sequencer check failure or transaction abort.
|
|
86
|
-
//
|
|
87
|
-
// See the guidelines above for deciding between `FAILED_PRECONDITION`,
|
|
88
|
-
// `ABORTED`, and `UNAVAILABLE`.
|
|
89
|
-
//
|
|
90
|
-
// HTTP Mapping: 409 Conflict
|
|
91
|
-
ABORTED: 409,
|
|
92
|
-
// The operation was attempted past the valid range. E.g., seeking or
|
|
93
|
-
// reading past end-of-file.
|
|
94
|
-
//
|
|
95
|
-
// Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
|
|
96
|
-
// be fixed if the system state changes. For example, a 32-bit file
|
|
97
|
-
// system will generate `INVALID_ARGUMENT` if asked to read at an
|
|
98
|
-
// offset that is not in the range [0,2^32-1], but it will generate
|
|
99
|
-
// `OUT_OF_RANGE` if asked to read from an offset past the current
|
|
100
|
-
// file size.
|
|
101
|
-
//
|
|
102
|
-
// There is a fair bit of overlap between `FAILED_PRECONDITION` and
|
|
103
|
-
// `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific
|
|
104
|
-
// error) when it applies so that callers who are iterating through
|
|
105
|
-
// a space can easily look for an `OUT_OF_RANGE` error to detect when
|
|
106
|
-
// they are done.
|
|
107
|
-
//
|
|
108
|
-
// HTTP Mapping: 400 Bad Request
|
|
109
|
-
OUT_OF_RANGE: 400,
|
|
110
|
-
// The operation is not implemented or is not supported/enabled in this
|
|
111
|
-
// service.
|
|
112
|
-
//
|
|
113
|
-
// HTTP Mapping: 501 Not Implemented
|
|
114
|
-
UNIMPLEMENTED: 501,
|
|
115
|
-
// Internal errors. This means that some invariants expected by the
|
|
116
|
-
// underlying system have been broken. This error code is reserved
|
|
117
|
-
// for serious errors.
|
|
118
|
-
//
|
|
119
|
-
// HTTP Mapping: 500 Internal Server Error
|
|
120
|
-
INTERNAL: 500,
|
|
121
|
-
// The service is currently unavailable. This is most likely a
|
|
122
|
-
// transient condition, which can be corrected by retrying with
|
|
123
|
-
// a backoff. Note that it is not always safe to retry
|
|
124
|
-
// non-idempotent operations.
|
|
125
|
-
//
|
|
126
|
-
// See the guidelines above for deciding between `FAILED_PRECONDITION`,
|
|
127
|
-
// `ABORTED`, and `UNAVAILABLE`.
|
|
128
|
-
//
|
|
129
|
-
// HTTP Mapping: 503 Service Unavailable
|
|
130
|
-
UNAVAILABLE: 503,
|
|
131
|
-
// Unrecoverable data loss or corruption.
|
|
132
|
-
//
|
|
133
|
-
// HTTP Mapping: 500 Internal Server Error
|
|
134
|
-
DATA_LOSS: 500,
|
|
135
|
-
// The request does not have valid authentication credentials for the
|
|
136
|
-
// operation.
|
|
137
|
-
//
|
|
138
|
-
// HTTP Mapping: 401 Unauthorized
|
|
139
|
-
UNAUTHENTICATED: 401,
|
|
140
|
-
// The request method is not supported by the server and cannot be handled.
|
|
141
|
-
//
|
|
142
|
-
// HTTP Mapping: 405 Method Not Allowed
|
|
143
|
-
METHOD_NOT_ALLOWED: 405
|
|
144
|
-
};
|
|
145
|
-
var DEFAULT_MESSAGES = {
|
|
146
|
-
OK: "OK",
|
|
147
|
-
CANCELLED: "The operation was cancelled",
|
|
148
|
-
UNKNOWN: "Unknown error",
|
|
149
|
-
INVALID_ARGUMENT: "The client specified an invalid argument",
|
|
150
|
-
DEADLINE_EXCEEDED: "The deadline expired before the operation could complete",
|
|
151
|
-
NOT_FOUND: "Some requested entity was not found",
|
|
152
|
-
ALREADY_EXISTS: "The entity that a client attempted to create already exists",
|
|
153
|
-
PERMISSION_DENIED: "The caller does not have permission to execute the specified operation",
|
|
154
|
-
RESOURCE_EXHAUSTED: "Some resource has been exhausted",
|
|
155
|
-
FAILED_PRECONDITION: "The operation was rejected because the system is not in a state required for the operation's execution",
|
|
156
|
-
ABORTED: "The operation was aborted",
|
|
157
|
-
OUT_OF_RANGE: "The operation was attempted past the valid range",
|
|
158
|
-
UNIMPLEMENTED: "The operation is not implemented or is not supported/enabled in this service",
|
|
159
|
-
INTERNAL: "Internal errors",
|
|
160
|
-
UNAVAILABLE: "The service is currently unavailable",
|
|
161
|
-
DATA_LOSS: "Unrecoverable data loss or corruption",
|
|
162
|
-
UNAUTHENTICATED: "The request does not have valid authentication credentials for the operation",
|
|
163
|
-
METHOD_NOT_ALLOWED: "The request method is not supported by the server and cannot be handled"
|
|
164
|
-
};
|
|
165
|
-
var StatusError = class _StatusError extends Error {
|
|
166
|
-
status;
|
|
167
|
-
body;
|
|
168
|
-
constructor(status, body) {
|
|
169
|
-
super(body?.error?.message ?? `Status Error: ${status}`);
|
|
170
|
-
this.name = "StatusError";
|
|
171
|
-
this.status = status;
|
|
172
|
-
this.body = body;
|
|
173
|
-
if (Error.captureStackTrace) {
|
|
174
|
-
Error.captureStackTrace(this, _StatusError);
|
|
175
|
-
}
|
|
176
|
-
Object.setPrototypeOf(this, _StatusError.prototype);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
var StatusCode = class _StatusCode {
|
|
180
|
-
code;
|
|
181
|
-
message;
|
|
182
|
-
constructor(code, message) {
|
|
183
|
-
this.code = code;
|
|
184
|
-
this.message = message;
|
|
185
|
-
}
|
|
186
|
-
static of(code, message) {
|
|
187
|
-
return new _StatusCode(code, message ?? DEFAULT_MESSAGES[code]);
|
|
188
|
-
}
|
|
189
|
-
body(details) {
|
|
190
|
-
return {
|
|
191
|
-
error: {
|
|
192
|
-
code: Code[this.code],
|
|
193
|
-
status: this.code,
|
|
194
|
-
message: this.message ?? "",
|
|
195
|
-
details: details?.list ?? []
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
error(details) {
|
|
200
|
-
const body = this.body(details);
|
|
201
|
-
if (Status.adapter) return Status.adapter(Code[this.code], body);
|
|
202
|
-
return new StatusError(Code[this.code], body);
|
|
203
|
-
}
|
|
204
|
-
response(details) {
|
|
205
|
-
const body = this.body(details);
|
|
206
|
-
return Response.json(body, { status: body.error.code });
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
var Status = class {
|
|
210
|
-
static adapter;
|
|
211
|
-
static ok = (message) => StatusCode.of("OK", message);
|
|
212
|
-
static cancelled = (message) => StatusCode.of("CANCELLED", message);
|
|
213
|
-
static unknown = (message) => StatusCode.of("UNKNOWN", message);
|
|
214
|
-
static invalidArgument = (message) => StatusCode.of("INVALID_ARGUMENT", message);
|
|
215
|
-
static deadlineExceeded = (message) => StatusCode.of("DEADLINE_EXCEEDED", message);
|
|
216
|
-
static notFound = (message) => StatusCode.of("NOT_FOUND", message);
|
|
217
|
-
static alreadyExists = (message) => StatusCode.of("ALREADY_EXISTS", message);
|
|
218
|
-
static permissionDenied = (message) => StatusCode.of("PERMISSION_DENIED", message);
|
|
219
|
-
static unauthorized = (message) => StatusCode.of("UNAUTHENTICATED", message);
|
|
220
|
-
static resourceExhausted = (message) => StatusCode.of("RESOURCE_EXHAUSTED", message);
|
|
221
|
-
static failedPrecondition = (message) => StatusCode.of("FAILED_PRECONDITION", message);
|
|
222
|
-
static aborted = (message) => StatusCode.of("ABORTED", message);
|
|
223
|
-
static outOfRange = (message) => StatusCode.of("OUT_OF_RANGE", message);
|
|
224
|
-
static unimplemented = (message) => StatusCode.of("UNIMPLEMENTED", message);
|
|
225
|
-
static internal = (message) => StatusCode.of("INTERNAL", message);
|
|
226
|
-
static unavailable = (message) => StatusCode.of("UNAVAILABLE", message);
|
|
227
|
-
static dataLoss = (message) => StatusCode.of("DATA_LOSS", message);
|
|
228
|
-
static methodNotAllowed = (message) => StatusCode.of("METHOD_NOT_ALLOWED", message);
|
|
229
|
-
};
|
|
230
|
-
export {
|
|
231
|
-
Code,
|
|
232
|
-
DEFAULT_MESSAGES,
|
|
233
|
-
Status,
|
|
234
|
-
StatusCode,
|
|
235
|
-
StatusError
|
|
236
|
-
};
|
|
237
|
-
//# sourceMappingURL=status.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was cancelled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error?.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n if ((Error as any).captureStackTrace) {\n (Error as any).captureStackTrace(this, StatusError);\n }\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n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AA,EAC/E,OAAO,WAAW,CAAC,YAAqB,WAAW,GAAG,aAAa,OAAO;AAAA,EAC1E,OAAO,mBAAmB,CAAC,YAAqB,WAAW,GAAG,sBAAsB,OAAO;AAC7F;","names":[]}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/google-one-tap/index.ts
|
|
21
|
-
var google_one_tap_exports = {};
|
|
22
|
-
__export(google_one_tap_exports, {
|
|
23
|
-
prompt: () => prompt
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(google_one_tap_exports);
|
|
26
|
-
function prompt({ clientId, callback }) {
|
|
27
|
-
const scriptId = "google-one-tap";
|
|
28
|
-
const script = document.createElement("script");
|
|
29
|
-
script.id = scriptId;
|
|
30
|
-
script.async = true;
|
|
31
|
-
script.defer = true;
|
|
32
|
-
script.src = "https://accounts.google.com/gsi/client";
|
|
33
|
-
script.onload = () => {
|
|
34
|
-
window.google.accounts.id.initialize({
|
|
35
|
-
ux_mode: "popup",
|
|
36
|
-
context: "signin",
|
|
37
|
-
auto_select: false,
|
|
38
|
-
client_id: clientId,
|
|
39
|
-
use_fedcm_for_prompt: true,
|
|
40
|
-
cancel_on_tap_outside: false,
|
|
41
|
-
callback
|
|
42
|
-
});
|
|
43
|
-
window.google?.accounts?.id?.prompt();
|
|
44
|
-
};
|
|
45
|
-
document.head.appendChild(script);
|
|
46
|
-
}
|
|
47
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
-
0 && (module.exports = {
|
|
49
|
-
prompt
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type { GoogleAccounts, CredentialResponse } from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n clientId: string;\n callback: (response: CredentialResponse) => void | Promise<void>;\n};\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport function prompt({ clientId, callback }: Props) {\n const scriptId = 'google-one-tap';\n const script = document.createElement('script');\n script.id = scriptId;\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select: false,\n client_id: clientId,\n use_fedcm_for_prompt: true,\n cancel_on_tap_outside: false,\n callback,\n });\n window.google?.accounts?.id?.prompt();\n };\n\n document.head.appendChild(script);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,OAAO,EAAE,UAAU,SAAS,GAAU;AACpD,QAAM,WAAW;AACjB,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,SAAO,MAAM;AACb,SAAO,SAAS,MAAM;AACpB,WAAO,OAAO,SAAS,GAAG,WAAW;AAAA,MACnC,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB;AAAA,IACF,CAAC;AACD,WAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,EACtC;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { GoogleAccounts, CredentialResponse } from './types.cjs';
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
google: {
|
|
6
|
-
accounts: GoogleAccounts;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
type Props = {
|
|
11
|
-
clientId: string;
|
|
12
|
-
callback: (response: CredentialResponse) => void | Promise<void>;
|
|
13
|
-
};
|
|
14
|
-
/** debug: chrome://settings/content/federatedIdentityApi */
|
|
15
|
-
declare function prompt({ clientId, callback }: Props): void;
|
|
16
|
-
|
|
17
|
-
export { type Props, prompt };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { GoogleAccounts, CredentialResponse } from './types.js';
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
google: {
|
|
6
|
-
accounts: GoogleAccounts;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
type Props = {
|
|
11
|
-
clientId: string;
|
|
12
|
-
callback: (response: CredentialResponse) => void | Promise<void>;
|
|
13
|
-
};
|
|
14
|
-
/** debug: chrome://settings/content/federatedIdentityApi */
|
|
15
|
-
declare function prompt({ clientId, callback }: Props): void;
|
|
16
|
-
|
|
17
|
-
export { type Props, prompt };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/google-one-tap/index.ts
|
|
2
|
-
function prompt({ clientId, callback }) {
|
|
3
|
-
const scriptId = "google-one-tap";
|
|
4
|
-
const script = document.createElement("script");
|
|
5
|
-
script.id = scriptId;
|
|
6
|
-
script.async = true;
|
|
7
|
-
script.defer = true;
|
|
8
|
-
script.src = "https://accounts.google.com/gsi/client";
|
|
9
|
-
script.onload = () => {
|
|
10
|
-
window.google.accounts.id.initialize({
|
|
11
|
-
ux_mode: "popup",
|
|
12
|
-
context: "signin",
|
|
13
|
-
auto_select: false,
|
|
14
|
-
client_id: clientId,
|
|
15
|
-
use_fedcm_for_prompt: true,
|
|
16
|
-
cancel_on_tap_outside: false,
|
|
17
|
-
callback
|
|
18
|
-
});
|
|
19
|
-
window.google?.accounts?.id?.prompt();
|
|
20
|
-
};
|
|
21
|
-
document.head.appendChild(script);
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
prompt
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type { GoogleAccounts, CredentialResponse } from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n clientId: string;\n callback: (response: CredentialResponse) => void | Promise<void>;\n};\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport function prompt({ clientId, callback }: Props) {\n const scriptId = 'google-one-tap';\n const script = document.createElement('script');\n script.id = scriptId;\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select: false,\n client_id: clientId,\n use_fedcm_for_prompt: true,\n cancel_on_tap_outside: false,\n callback,\n });\n window.google?.accounts?.id?.prompt();\n };\n\n document.head.appendChild(script);\n}\n"],"mappings":";AAgBO,SAAS,OAAO,EAAE,UAAU,SAAS,GAAU;AACpD,QAAM,WAAW;AACjB,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,SAAO,MAAM;AACb,SAAO,SAAS,MAAM;AACpB,WAAO,OAAO,SAAS,GAAG,WAAW;AAAA,MACnC,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB;AAAA,IACF,CAAC;AACD,WAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,EACtC;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/google-one-tap/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
19
|
-
//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/google-one-tap/types.ts"],"sourcesContent":["interface ClientConfigError extends Error {\n message: string;\n stack?: string;\n type: 'unknown' | 'popup_closed' | 'popup_failed_to_open';\n}\n\ninterface OverridableTokenClientConfig {\n scope?: string;\n include_granted_scopes?: boolean;\n prompt?: string;\n enable_granular_consent?: boolean;\n enable_serial_consent?: boolean;\n login_hint?: string;\n hint?: string;\n state?: string;\n}\n\ninterface TokenClient {\n requestAccessToken: (overrideConfig?: OverridableTokenClientConfig) => void;\n}\n\ninterface CodeClient {\n requestCode: () => void;\n}\n\ninterface TokenResponse {\n access_token: string;\n expires_in: string;\n hd: string;\n prompt: string;\n token_type: string;\n scope: string;\n state: string;\n error: string;\n error_description: string;\n error_uri: string;\n}\n\ninterface CodeResponse {\n code: string;\n scope: string;\n state: string;\n error: string;\n error_description: string;\n error_uri: string;\n}\n\ninterface TokenClientConfig {\n client_id: string;\n scope: string;\n include_granted_scopes?: boolean;\n prompt?: '' | 'none' | 'consent' | 'select_account';\n enable_granular_consent?: boolean;\n enable_serial_consent?: boolean;\n login_hint?: string;\n hint?: string;\n hd?: string;\n hosted_domain?: string;\n state?: string;\n callback: (tokenResponse: TokenResponse) => void;\n error_callback?: (error: ClientConfigError) => void;\n}\n\ninterface CodeClientConfig {\n client_id: string;\n scope: string;\n include_granted_scopes?: boolean;\n redirect_uri?: string;\n state?: string;\n enable_granular_consent?: boolean;\n enable_serial_consent?: boolean;\n login_hint?: string;\n hint?: string;\n hd?: string;\n hosted_domain?: string;\n ux_mode?: 'popup' | 'redirect';\n select_account?: boolean;\n callback?: (response: CodeResponse) => void;\n error_callback?: (error: ClientConfigError) => void;\n}\n\ninterface RevocationResponse {\n successful: boolean;\n error?: string;\n}\n\ninterface Credential {\n id: string;\n password: string;\n}\n\nexport interface CredentialResponse {\n credential: string;\n select_by: string;\n}\n\nexport interface IdConfiguration {\n client_id: string;\n auto_select?: boolean;\n login_uri?: string;\n cancel_on_tap_outside?: boolean;\n prompt_parent_id?: string;\n nonce?: string;\n context?: 'signin' | 'signup' | 'use';\n state_cookie_domain?: string;\n ux_mode?: 'popup' | 'redirect';\n allowed_parent_origin?: string | string[];\n itp_support?: boolean;\n login_hint?: string;\n hd?: string;\n use_fedcm_for_prompt?: boolean;\n callback?: (response: CredentialResponse) => void;\n native_callback?: (response: CredentialResponse) => void;\n intermediate_iframe_close_callback?: () => void;\n}\n/**\n * ref: https://developers.google.com/identity/gsi/web/guides/fedcm-migration?s=dc&utm_source=devtools&utm_campaign=stable#display_moment\n */\nexport interface PromptMomentNotification {\n /** @deprecated */\n isDisplayMoment(): boolean;\n\n /** @deprecated */\n isDisplayed(): boolean;\n\n /** @deprecated */\n isNotDisplayed(): boolean;\n\n /** @deprecated */\n getNotDisplayedReason():\n | 'browser_not_supported'\n | 'invalid_client'\n | 'missing_client_id'\n | 'opt_out_or_no_session'\n | 'secure_http_required'\n | 'suppressed_by_user'\n | 'unregistered_origin'\n | 'unknown_reason';\n\n /** @deprecated */\n getSkippedReason(): 'auto_cancel' | 'user_cancel' | 'tap_outside' | 'issuing_failed';\n\n isSkippedMoment(): boolean;\n isDismissedMoment(): boolean;\n getDismissedReason(): 'credential_returned' | 'cancel_called' | 'flow_restarted';\n getMomentType(): 'display' | 'skipped' | 'dismissed';\n}\n\ninterface GsiButtonConfiguration {\n type: 'standard' | 'icon';\n theme?: 'outline' | 'filled_blue' | 'filled_black';\n size?: 'small' | 'medium' | 'large';\n text?: 'signin_with' | 'signup_with' | 'continue_with' | 'signin';\n shape?: 'rectangular' | 'pill' | 'circle' | 'square';\n logo_alignment?: 'left' | 'center';\n width?: number;\n locale?: string;\n state?: string;\n click_listener?: () => void;\n}\n\nexport interface GoogleAccounts {\n oauth2: {\n initCodeClient(config: CodeClientConfig): CodeClient;\n initTokenClient(config: TokenClientConfig): TokenClient;\n hasGrantedAllScopes(\n tokenResponse: TokenResponse,\n firstScope: string,\n ...restScopes: string[]\n ): boolean;\n hasGrantedAnyScope(\n tokenResponse: TokenResponse,\n firstScope: string,\n ...restScopes: string[]\n ): boolean;\n revoke(accessToken: string, done: () => void): void;\n };\n id: {\n initialize(idConfig: IdConfiguration): void;\n prompt(momentListener?: (promptMomentNotification: PromptMomentNotification) => void): void;\n renderButton(parent: HTMLElement, options: GsiButtonConfiguration): void;\n disableAutoSelect(): void;\n storeCredential(credential: Credential, callback?: () => void): void;\n cancel(): void;\n revoke(hint: string, callback?: (response: RevocationResponse) => void): void;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|