@grow-codes/oidc 0.0.0-stage → 0.1.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/AGENTS.md +120 -0
- package/LICENSE +202 -0
- package/NOTICE +61 -0
- package/README.md +30 -2
- package/lib/chunk-4JJJPKI5.js +233 -0
- package/lib/chunk-4JJJPKI5.js.map +1 -0
- package/lib/chunk-WO2QXDBJ.cjs +255 -0
- package/lib/chunk-WO2QXDBJ.cjs.map +1 -0
- package/lib/index.cjs +1899 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +717 -0
- package/lib/index.d.ts +717 -0
- package/lib/index.js +1748 -0
- package/lib/index.js.map +1 -0
- package/lib/testing/index.cjs +588 -0
- package/lib/testing/index.cjs.map +1 -0
- package/lib/testing/index.d.cts +280 -0
- package/lib/testing/index.d.ts +280 -0
- package/lib/testing/index.js +566 -0
- package/lib/testing/index.js.map +1 -0
- package/lib/verifier-ERmLmytF.d.cts +211 -0
- package/lib/verifier-ERmLmytF.d.ts +211 -0
- package/package.json +106 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/errors.ts","../src/core/abort.ts","../src/core/poll.ts"],"names":["sleep"],"mappings":";AAGO,IAAM,SAAA,GAAY;AAAA,EACvB,MAAA,EAAQ,QAAA;AAAA,EACR,cAAA,EAAgB,gBAAA;AAAA,EAChB,gBAAA,EAAkB,mBAAA;AAAA,EAClB,QAAA,EAAU,WAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,WAAA,EAAa,cAAA;AAAA,EACb,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa,aAAA;AAAA,EACb,OAAA,EAAS,SAAA;AAAA,EACT,WAAA,EAAa,aAAA;AAAA,EACb,SAAA,EAAW;AACb;AAKA,IAAM,oBAAA,uBAAmD,GAAA,CAAe;AAAA,EACtE,SAAA,CAAU,WAAA;AAAA,EACV,SAAA,CAAU,WAAA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AY,GAAA;AAAA,IACd;AACA,IAAA,MAAM,SAAA,GAAY,WAAW,GAAA,EAAI;AACjC,IAAA,IAAI,aAAa,CAAA,EAAG;AAClB,MAAA,MAAM,IAAI,YAAA;AAAA,QACR,CAAA,EAAG,SAAS,CAAA,2BAAA,EAA8B,SAAS,aAAa,OAAO,CAAA,SAAA,CAAA;AAAA,QACvE,cAAc,MAAA,GAAY,EAAC,GAAI,EAAE,OAAO,SAAA;AAAU,OACpD;AAAA,IACF;AACA,IAAA,MAAMA,OAAM,IAAA,CAAK,GAAA,CAAI,YAAY,SAAS,CAAA,EAAG,QAAQ,MAAM,CAAA;AAAA,EAC7D;AACF","file":"chunk-4JJJPKI5.js","sourcesContent":["// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\n/** Canonical error codes shared by every Grow Codes SDK (SPEC §2.1). Values are the wire form. */\nexport const ErrorCode = {\n Config: \"CONFIG\",\n Authentication: \"AUTHENTICATION\",\n PermissionDenied: \"PERMISSION_DENIED\",\n NotFound: \"NOT_FOUND\",\n Conflict: \"CONFLICT\",\n RateLimited: \"RATE_LIMITED\",\n Validation: \"VALIDATION\",\n Unavailable: \"UNAVAILABLE\",\n Timeout: \"TIMEOUT\",\n Unsupported: \"UNSUPPORTED\",\n Cancelled: \"CANCELLED\",\n} as const;\n\n/** One of the {@link ErrorCode} wire values, e.g. `\"NOT_FOUND\"`. */\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nconst RETRYABLE_BY_DEFAULT: ReadonlySet<ErrorCode> = new Set<ErrorCode>([\n ErrorCode.RateLimited,\n ErrorCode.Unavailable,\n ErrorCode.Timeout,\n]);\n\n/** Optional details attached to an SDK error. */\nexport interface ErrorDetails {\n /** HTTP status when the error came from a response. */\n httpStatus?: number;\n /** Vendor request id header when present. */\n requestId?: string;\n /** Overrides the default retryability of the code. */\n retryable?: boolean;\n /** Server-requested wait (from `Retry-After`) in milliseconds. */\n retryAfterMs?: number;\n /** Underlying error (already redacted). */\n cause?: unknown;\n}\n\n/**\n * Base class of every error thrown by the OIDC SDK.\n *\n * The message never contains credentials, request bodies or unfiltered response bodies.\n */\nexport class OidcError extends Error {\n /** Canonical error code. */\n readonly code: ErrorCode;\n /** HTTP status when the error came from a response. */\n readonly httpStatus?: number;\n /** Vendor request id when the response carried one. */\n readonly requestId?: string;\n /** Whether retrying the same call may succeed. */\n readonly retryable: boolean;\n /** Server-requested wait in milliseconds (rate limits, `Retry-After`). */\n readonly retryAfterMs?: number;\n\n constructor(code: ErrorCode, message: string, details: ErrorDetails = {}) {\n super(message, details.cause === undefined ? undefined : { cause: details.cause });\n this.name = new.target.name;\n this.code = code;\n this.retryable = details.retryable ?? RETRYABLE_BY_DEFAULT.has(code);\n if (details.httpStatus !== undefined) this.httpStatus = details.httpStatus;\n if (details.requestId !== undefined) this.requestId = details.requestId;\n if (details.retryAfterMs !== undefined) this.retryAfterMs = details.retryAfterMs;\n }\n\n /** JSON form (no stack, no cause). */\n toJSON(): Record<string, unknown> {\n const out: Record<string, unknown> = {\n name: this.name,\n code: this.code,\n message: this.message,\n retryable: this.retryable,\n };\n if (this.httpStatus !== undefined) out.httpStatus = this.httpStatus;\n if (this.requestId !== undefined) out.requestId = this.requestId;\n if (this.retryAfterMs !== undefined) out.retryAfterMs = this.retryAfterMs;\n return out;\n }\n}\n\n/** Invalid or missing configuration. */\nexport class ConfigError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Config, message, details);\n }\n}\n\n/** HTTP 401: missing or invalid credentials. */\nexport class AuthenticationError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Authentication, message, details);\n }\n}\n\n/** HTTP 403: the credentials do not allow the operation. */\nexport class PermissionDeniedError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.PermissionDenied, message, details);\n }\n}\n\n/** HTTP 404 or a missing record. */\nexport class NotFoundError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.NotFound, message, details);\n }\n}\n\n/** HTTP 409/412 or a compare-and-set mismatch. */\nexport class ConflictError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Conflict, message, details);\n }\n}\n\n/** HTTP 429. `retryAfterMs` is set when the server sent `Retry-After`. */\nexport class RateLimitError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.RateLimited, message, details);\n }\n}\n\n/** HTTP 400/413/422/other 4xx, or bad input caught client side. */\nexport class ValidationError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Validation, message, details);\n }\n}\n\n/** Network error or HTTP 500/502/503. */\nexport class UnavailableError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Unavailable, message, details);\n }\n}\n\n/** A connect, request or total deadline was exceeded, or HTTP 408/504. */\nexport class TimeoutError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Timeout, message, details);\n }\n}\n\n/** The service or deployment does not offer the capability (HTTP 501, missing API). */\nexport class UnsupportedError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Unsupported, message, details);\n }\n}\n\n/** The caller cancelled the operation (AbortSignal). */\nexport class CancelledError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Cancelled, message, details);\n }\n}\n\ntype ErrorClass = new (message: string, details?: ErrorDetails) => OidcError;\n\nconst CLASS_BY_CODE: Record<ErrorCode, ErrorClass> = {\n CONFIG: ConfigError,\n AUTHENTICATION: AuthenticationError,\n PERMISSION_DENIED: PermissionDeniedError,\n NOT_FOUND: NotFoundError,\n CONFLICT: ConflictError,\n RATE_LIMITED: RateLimitError,\n VALIDATION: ValidationError,\n UNAVAILABLE: UnavailableError,\n TIMEOUT: TimeoutError,\n UNSUPPORTED: UnsupportedError,\n CANCELLED: CancelledError,\n};\n\nconst REASON_BY_CODE: Record<ErrorCode, string> = {\n CONFIG: \"invalid configuration\",\n AUTHENTICATION: \"authentication failed\",\n PERMISSION_DENIED: \"permission denied\",\n NOT_FOUND: \"not found\",\n CONFLICT: \"conflict\",\n RATE_LIMITED: \"rate limited\",\n VALIDATION: \"invalid request\",\n UNAVAILABLE: \"service unavailable\",\n TIMEOUT: \"timed out\",\n UNSUPPORTED: \"not supported\",\n CANCELLED: \"cancelled\",\n};\n\n/** Creates the subclass that matches `code`. */\nexport function errorForCode(\n code: ErrorCode,\n message: string,\n details?: ErrorDetails,\n): OidcError {\n return new CLASS_BY_CODE[code](message, details);\n}\n\n/** Default short reason for a code, used in messages such as `\"op: not found (HTTP 404)\"`. */\nexport function reasonForCode(code: ErrorCode): string {\n return REASON_BY_CODE[code];\n}\n\n/** Maps an HTTP status (>= 400) to its canonical {@link ErrorCode} (SPEC §2.1). */\nexport function codeForStatus(status: number): ErrorCode {\n switch (status) {\n case 401:\n return ErrorCode.Authentication;\n case 403:\n return ErrorCode.PermissionDenied;\n case 404:\n return ErrorCode.NotFound;\n case 409:\n case 412:\n return ErrorCode.Conflict;\n case 429:\n return ErrorCode.RateLimited;\n case 408:\n case 504:\n return ErrorCode.Timeout;\n case 501:\n return ErrorCode.Unsupported;\n default:\n return status >= 500 ? ErrorCode.Unavailable : ErrorCode.Validation;\n }\n}\n\n/** Builds the error for an HTTP error response: `\"<operation>: <reason> (HTTP <status>)\"`. */\nexport function errorForStatus(\n operation: string,\n status: number,\n details: Omit<ErrorDetails, \"httpStatus\"> & { reason?: string } = {},\n): OidcError {\n const code = codeForStatus(status);\n const { reason, ...rest } = details;\n const text = reason !== undefined && reason !== \"\" ? reason : reasonForCode(code);\n return errorForCode(code, `${operation}: ${text} (HTTP ${status})`, {\n ...rest,\n httpStatus: status,\n });\n}\n\n/** True when `err` is an SDK error (optionally with the given code). */\nexport function isOidcError(err: unknown, code?: ErrorCode): err is OidcError {\n return err instanceof OidcError && (code === undefined || err.code === code);\n}\n","// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\nimport { CancelledError } from \"./errors.js\";\n\n/** Throws {@link CancelledError} when the signal is already aborted. */\nexport function throwIfAborted(signal: AbortSignal | undefined, operation: string): void {\n if (signal?.aborted === true) throw new CancelledError(`${operation}: cancelled`);\n}\n\n/**\n * Resolves after `ms` milliseconds; rejects with {@link CancelledError} when `signal` aborts\n * first. The timer does not keep the process alive.\n */\nexport function sleep(ms: number, signal?: AbortSignal, operation = \"sleep\"): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (signal?.aborted === true) {\n reject(new CancelledError(`${operation}: cancelled`));\n return;\n }\n const onAbort = (): void => {\n clearTimeout(timer);\n reject(new CancelledError(`${operation}: cancelled`));\n };\n const timer = setTimeout(\n () => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n },\n Math.max(0, ms),\n );\n timer.unref();\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n","// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\nimport { sleep as defaultSleep, throwIfAborted } from \"./abort.js\";\nimport { TimeoutError } from \"./errors.js\";\n\n/** Options of {@link pollUntil}. */\nexport interface PollOptions {\n /** Give up after this many ms (default 30 000). */\n timeoutMs?: number;\n /** Wait between attempts in ms (default 1 000). */\n intervalMs?: number;\n /** Caller cancellation. */\n signal?: AbortSignal;\n /** Name used in the timeout message (default `\"poll\"`). */\n operation?: string;\n /** Errors for which polling continues instead of failing (default: none). */\n ignoreError?: (error: unknown) => boolean;\n /** Test seam. */\n sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;\n /** Test seam: clock in ms. */\n now?: () => number;\n}\n\n/**\n * Calls `fn` until `predicate(value)` is true and returns that value. Throws\n * {@link TimeoutError} when the time budget runs out (the message includes the last value's\n * failure reason when the predicate never matched) and `CancelledError` on abort.\n */\nexport async function pollUntil<T>(\n fn: (attempt: number) => Promise<T>,\n predicate: (value: T) => boolean,\n options: PollOptions = {},\n): Promise<T> {\n const timeoutMs = options.timeoutMs ?? 30_000;\n const intervalMs = options.intervalMs ?? 1_000;\n const operation = options.operation ?? \"poll\";\n const sleep = options.sleep ?? defaultSleep;\n const now = options.now ?? Date.now;\n const deadline = now() + timeoutMs;\n let lastError: unknown;\n for (let attempt = 1; ; attempt++) {\n throwIfAborted(options.signal, operation);\n try {\n const value = await fn(attempt);\n if (predicate(value)) return value;\n } catch (err) {\n if (options.ignoreError?.(err) !== true) throw err;\n lastError = err;\n }\n const remaining = deadline - now();\n if (remaining <= 0) {\n throw new TimeoutError(\n `${operation}: condition not met within ${timeoutMs} ms after ${attempt} attempts`,\n lastError === undefined ? {} : { cause: lastError },\n );\n }\n await sleep(Math.min(intervalMs, remaining), options.signal);\n }\n}\n"]}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/core/errors.ts
|
|
4
|
+
var ErrorCode = {
|
|
5
|
+
Config: "CONFIG",
|
|
6
|
+
Authentication: "AUTHENTICATION",
|
|
7
|
+
PermissionDenied: "PERMISSION_DENIED",
|
|
8
|
+
NotFound: "NOT_FOUND",
|
|
9
|
+
Conflict: "CONFLICT",
|
|
10
|
+
RateLimited: "RATE_LIMITED",
|
|
11
|
+
Validation: "VALIDATION",
|
|
12
|
+
Unavailable: "UNAVAILABLE",
|
|
13
|
+
Timeout: "TIMEOUT",
|
|
14
|
+
Unsupported: "UNSUPPORTED",
|
|
15
|
+
Cancelled: "CANCELLED"
|
|
16
|
+
};
|
|
17
|
+
var RETRYABLE_BY_DEFAULT = /* @__PURE__ */ new Set([
|
|
18
|
+
ErrorCode.RateLimited,
|
|
19
|
+
ErrorCode.Unavailable,
|
|
20
|
+
ErrorCode.Timeout
|
|
21
|
+
]);
|
|
22
|
+
var OidcError = class extends Error {
|
|
23
|
+
/** Canonical error code. */
|
|
24
|
+
code;
|
|
25
|
+
/** HTTP status when the error came from a response. */
|
|
26
|
+
httpStatus;
|
|
27
|
+
/** Vendor request id when the response carried one. */
|
|
28
|
+
requestId;
|
|
29
|
+
/** Whether retrying the same call may succeed. */
|
|
30
|
+
retryable;
|
|
31
|
+
/** Server-requested wait in milliseconds (rate limits, `Retry-After`). */
|
|
32
|
+
retryAfterMs;
|
|
33
|
+
constructor(code, message, details = {}) {
|
|
34
|
+
super(message, details.cause === void 0 ? void 0 : { cause: details.cause });
|
|
35
|
+
this.name = new.target.name;
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.retryable = details.retryable ?? RETRYABLE_BY_DEFAULT.has(code);
|
|
38
|
+
if (details.httpStatus !== void 0) this.httpStatus = details.httpStatus;
|
|
39
|
+
if (details.requestId !== void 0) this.requestId = details.requestId;
|
|
40
|
+
if (details.retryAfterMs !== void 0) this.retryAfterMs = details.retryAfterMs;
|
|
41
|
+
}
|
|
42
|
+
/** JSON form (no stack, no cause). */
|
|
43
|
+
toJSON() {
|
|
44
|
+
const out = {
|
|
45
|
+
name: this.name,
|
|
46
|
+
code: this.code,
|
|
47
|
+
message: this.message,
|
|
48
|
+
retryable: this.retryable
|
|
49
|
+
};
|
|
50
|
+
if (this.httpStatus !== void 0) out.httpStatus = this.httpStatus;
|
|
51
|
+
if (this.requestId !== void 0) out.requestId = this.requestId;
|
|
52
|
+
if (this.retryAfterMs !== void 0) out.retryAfterMs = this.retryAfterMs;
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var ConfigError = class extends OidcError {
|
|
57
|
+
constructor(message, details) {
|
|
58
|
+
super(ErrorCode.Config, message, details);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var AuthenticationError = class extends OidcError {
|
|
62
|
+
constructor(message, details) {
|
|
63
|
+
super(ErrorCode.Authentication, message, details);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var PermissionDeniedError = class extends OidcError {
|
|
67
|
+
constructor(message, details) {
|
|
68
|
+
super(ErrorCode.PermissionDenied, message, details);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var NotFoundError = class extends OidcError {
|
|
72
|
+
constructor(message, details) {
|
|
73
|
+
super(ErrorCode.NotFound, message, details);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var ConflictError = class extends OidcError {
|
|
77
|
+
constructor(message, details) {
|
|
78
|
+
super(ErrorCode.Conflict, message, details);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var RateLimitError = class extends OidcError {
|
|
82
|
+
constructor(message, details) {
|
|
83
|
+
super(ErrorCode.RateLimited, message, details);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var ValidationError = class extends OidcError {
|
|
87
|
+
constructor(message, details) {
|
|
88
|
+
super(ErrorCode.Validation, message, details);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var UnavailableError = class extends OidcError {
|
|
92
|
+
constructor(message, details) {
|
|
93
|
+
super(ErrorCode.Unavailable, message, details);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var TimeoutError = class extends OidcError {
|
|
97
|
+
constructor(message, details) {
|
|
98
|
+
super(ErrorCode.Timeout, message, details);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var UnsupportedError = class extends OidcError {
|
|
102
|
+
constructor(message, details) {
|
|
103
|
+
super(ErrorCode.Unsupported, message, details);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var CancelledError = class extends OidcError {
|
|
107
|
+
constructor(message, details) {
|
|
108
|
+
super(ErrorCode.Cancelled, message, details);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var CLASS_BY_CODE = {
|
|
112
|
+
CONFIG: ConfigError,
|
|
113
|
+
AUTHENTICATION: AuthenticationError,
|
|
114
|
+
PERMISSION_DENIED: PermissionDeniedError,
|
|
115
|
+
NOT_FOUND: NotFoundError,
|
|
116
|
+
CONFLICT: ConflictError,
|
|
117
|
+
RATE_LIMITED: RateLimitError,
|
|
118
|
+
VALIDATION: ValidationError,
|
|
119
|
+
UNAVAILABLE: UnavailableError,
|
|
120
|
+
TIMEOUT: TimeoutError,
|
|
121
|
+
UNSUPPORTED: UnsupportedError,
|
|
122
|
+
CANCELLED: CancelledError
|
|
123
|
+
};
|
|
124
|
+
var REASON_BY_CODE = {
|
|
125
|
+
CONFIG: "invalid configuration",
|
|
126
|
+
AUTHENTICATION: "authentication failed",
|
|
127
|
+
PERMISSION_DENIED: "permission denied",
|
|
128
|
+
NOT_FOUND: "not found",
|
|
129
|
+
CONFLICT: "conflict",
|
|
130
|
+
RATE_LIMITED: "rate limited",
|
|
131
|
+
VALIDATION: "invalid request",
|
|
132
|
+
UNAVAILABLE: "service unavailable",
|
|
133
|
+
TIMEOUT: "timed out",
|
|
134
|
+
UNSUPPORTED: "not supported",
|
|
135
|
+
CANCELLED: "cancelled"
|
|
136
|
+
};
|
|
137
|
+
function errorForCode(code, message, details) {
|
|
138
|
+
return new CLASS_BY_CODE[code](message, details);
|
|
139
|
+
}
|
|
140
|
+
function reasonForCode(code) {
|
|
141
|
+
return REASON_BY_CODE[code];
|
|
142
|
+
}
|
|
143
|
+
function codeForStatus(status) {
|
|
144
|
+
switch (status) {
|
|
145
|
+
case 401:
|
|
146
|
+
return ErrorCode.Authentication;
|
|
147
|
+
case 403:
|
|
148
|
+
return ErrorCode.PermissionDenied;
|
|
149
|
+
case 404:
|
|
150
|
+
return ErrorCode.NotFound;
|
|
151
|
+
case 409:
|
|
152
|
+
case 412:
|
|
153
|
+
return ErrorCode.Conflict;
|
|
154
|
+
case 429:
|
|
155
|
+
return ErrorCode.RateLimited;
|
|
156
|
+
case 408:
|
|
157
|
+
case 504:
|
|
158
|
+
return ErrorCode.Timeout;
|
|
159
|
+
case 501:
|
|
160
|
+
return ErrorCode.Unsupported;
|
|
161
|
+
default:
|
|
162
|
+
return status >= 500 ? ErrorCode.Unavailable : ErrorCode.Validation;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function errorForStatus(operation, status, details = {}) {
|
|
166
|
+
const code = codeForStatus(status);
|
|
167
|
+
const { reason, ...rest } = details;
|
|
168
|
+
const text = reason !== void 0 && reason !== "" ? reason : reasonForCode(code);
|
|
169
|
+
return errorForCode(code, `${operation}: ${text} (HTTP ${status})`, {
|
|
170
|
+
...rest,
|
|
171
|
+
httpStatus: status
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function isOidcError(err, code) {
|
|
175
|
+
return err instanceof OidcError && (code === void 0 || err.code === code);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/core/abort.ts
|
|
179
|
+
function throwIfAborted(signal, operation) {
|
|
180
|
+
if (signal?.aborted === true) throw new CancelledError(`${operation}: cancelled`);
|
|
181
|
+
}
|
|
182
|
+
function sleep(ms, signal, operation = "sleep") {
|
|
183
|
+
return new Promise((resolve, reject) => {
|
|
184
|
+
if (signal?.aborted === true) {
|
|
185
|
+
reject(new CancelledError(`${operation}: cancelled`));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const onAbort = () => {
|
|
189
|
+
clearTimeout(timer);
|
|
190
|
+
reject(new CancelledError(`${operation}: cancelled`));
|
|
191
|
+
};
|
|
192
|
+
const timer = setTimeout(
|
|
193
|
+
() => {
|
|
194
|
+
signal?.removeEventListener("abort", onAbort);
|
|
195
|
+
resolve();
|
|
196
|
+
},
|
|
197
|
+
Math.max(0, ms)
|
|
198
|
+
);
|
|
199
|
+
timer.unref();
|
|
200
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/core/poll.ts
|
|
205
|
+
async function pollUntil(fn, predicate, options = {}) {
|
|
206
|
+
const timeoutMs = options.timeoutMs ?? 3e4;
|
|
207
|
+
const intervalMs = options.intervalMs ?? 1e3;
|
|
208
|
+
const operation = options.operation ?? "poll";
|
|
209
|
+
const sleep2 = options.sleep ?? sleep;
|
|
210
|
+
const now = options.now ?? Date.now;
|
|
211
|
+
const deadline = now() + timeoutMs;
|
|
212
|
+
let lastError;
|
|
213
|
+
for (let attempt = 1; ; attempt++) {
|
|
214
|
+
throwIfAborted(options.signal, operation);
|
|
215
|
+
try {
|
|
216
|
+
const value = await fn(attempt);
|
|
217
|
+
if (predicate(value)) return value;
|
|
218
|
+
} catch (err) {
|
|
219
|
+
if (options.ignoreError?.(err) !== true) throw err;
|
|
220
|
+
lastError = err;
|
|
221
|
+
}
|
|
222
|
+
const remaining = deadline - now();
|
|
223
|
+
if (remaining <= 0) {
|
|
224
|
+
throw new TimeoutError(
|
|
225
|
+
`${operation}: condition not met within ${timeoutMs} ms after ${attempt} attempts`,
|
|
226
|
+
lastError === void 0 ? {} : { cause: lastError }
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
await sleep2(Math.min(intervalMs, remaining), options.signal);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
exports.AuthenticationError = AuthenticationError;
|
|
234
|
+
exports.CancelledError = CancelledError;
|
|
235
|
+
exports.ConfigError = ConfigError;
|
|
236
|
+
exports.ConflictError = ConflictError;
|
|
237
|
+
exports.ErrorCode = ErrorCode;
|
|
238
|
+
exports.NotFoundError = NotFoundError;
|
|
239
|
+
exports.OidcError = OidcError;
|
|
240
|
+
exports.PermissionDeniedError = PermissionDeniedError;
|
|
241
|
+
exports.RateLimitError = RateLimitError;
|
|
242
|
+
exports.TimeoutError = TimeoutError;
|
|
243
|
+
exports.UnavailableError = UnavailableError;
|
|
244
|
+
exports.UnsupportedError = UnsupportedError;
|
|
245
|
+
exports.ValidationError = ValidationError;
|
|
246
|
+
exports.codeForStatus = codeForStatus;
|
|
247
|
+
exports.errorForCode = errorForCode;
|
|
248
|
+
exports.errorForStatus = errorForStatus;
|
|
249
|
+
exports.isOidcError = isOidcError;
|
|
250
|
+
exports.pollUntil = pollUntil;
|
|
251
|
+
exports.reasonForCode = reasonForCode;
|
|
252
|
+
exports.sleep = sleep;
|
|
253
|
+
exports.throwIfAborted = throwIfAborted;
|
|
254
|
+
//# sourceMappingURL=chunk-WO2QXDBJ.cjs.map
|
|
255
|
+
//# sourceMappingURL=chunk-WO2QXDBJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/errors.ts","../src/core/abort.ts","../src/core/poll.ts"],"names":["sleep"],"mappings":";;;AAGO,IAAM,SAAA,GAAY;AAAA,EACvB,MAAA,EAAQ,QAAA;AAAA,EACR,cAAA,EAAgB,gBAAA;AAAA,EAChB,gBAAA,EAAkB,mBAAA;AAAA,EAClB,QAAA,EAAU,WAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,WAAA,EAAa,cAAA;AAAA,EACb,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa,aAAA;AAAA,EACb,OAAA,EAAS,SAAA;AAAA,EACT,WAAA,EAAa,aAAA;AAAA,EACb,SAAA,EAAW;AACb;AAKA,IAAM,oBAAA,uBAAmD,GAAA,CAAe;AAAA,EACtE,SAAA,CAAU,WAAA;AAAA,EACV,SAAA,CAAU,WAAA;AAAA,EACV,SAAA,CAAU;AACZ,CAAC,CAAA;AAqBM,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA;AAAA,EAE1B,IAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,YAAA;AAAA,EAET,WAAA,CAAY,IAAA,EAAiB,OAAA,EAAiB,OAAA,GAAwB,EAAC,EAAG;AACxE,IAAA,KAAA,CAAM,OAAA,EAAS,QAAQ,KAAA,KAAU,MAAA,GAAY,SAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,CAAA;AACjF,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,SAAA,GAAY,OAAA,CAAQ,SAAA,IAAa,oBAAA,CAAqB,IA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C,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,MAAA;AACvC,EAAA,MAAMA,MAAAA,GAAQ,QAAQ,KAAA,IAAS,KAAA;AAC/B,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,IAAO,IAAA,CAAK,GAAA;AAChC,EAAA,MAAM,QAAA,GAAW,KAAI,GAAI,SAAA;AACzB,EAAA,IAAI,SAAA;AACJ,EAAA,KAAA,IAAS,OAAA,GAAU,KAAK,OAAA,EAAA,EAAW;AACjC,IAAA,cAAA,CAAe,OAAA,CAAQ,QAAQ,SAAS,CAAA;AACxC,IAAA,IAAI;AACF,MAAA,MAAM,KAAA,GAAQ,MAAM,EAAA,CAAG,OAAO,CAAA;AAC9B,MAAA,IAAI,SAAA,CAAU,KAAK,CAAA,EAAG,OAAO,KAAA;AAAA,IAC/B,SAAS,GAAA,EAAK;AACZ,MAAA,IAAI,OAAA,CAAQ,WAAA,GAAc,GAAG,CAAA,KAAM,MAAM,MAAM,GAAA;AAC/C,MAAA,SAAA,GAAY,GAAA;AAAA,IACd;AACA,IAAA,MAAM,SAAA,GAAY,WAAW,GAAA,EAAI;AACjC,IAAA,IAAI,aAAa,CAAA,EAAG;AAClB,MAAA,MAAM,IAAI,YAAA;AAAA,QACR,CAAA,EAAG,SAAS,CAAA,2BAAA,EAA8B,SAAS,aAAa,OAAO,CAAA,SAAA,CAAA;AAAA,QACvE,cAAc,MAAA,GAAY,EAAC,GAAI,EAAE,OAAO,SAAA;AAAU,OACpD;AAAA,IACF;AACA,IAAA,MAAMA,OAAM,IAAA,CAAK,GAAA,CAAI,YAAY,SAAS,CAAA,EAAG,QAAQ,MAAM,CAAA;AAAA,EAC7D;AACF","file":"chunk-WO2QXDBJ.cjs","sourcesContent":["// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\n/** Canonical error codes shared by every Grow Codes SDK (SPEC §2.1). Values are the wire form. */\nexport const ErrorCode = {\n Config: \"CONFIG\",\n Authentication: \"AUTHENTICATION\",\n PermissionDenied: \"PERMISSION_DENIED\",\n NotFound: \"NOT_FOUND\",\n Conflict: \"CONFLICT\",\n RateLimited: \"RATE_LIMITED\",\n Validation: \"VALIDATION\",\n Unavailable: \"UNAVAILABLE\",\n Timeout: \"TIMEOUT\",\n Unsupported: \"UNSUPPORTED\",\n Cancelled: \"CANCELLED\",\n} as const;\n\n/** One of the {@link ErrorCode} wire values, e.g. `\"NOT_FOUND\"`. */\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nconst RETRYABLE_BY_DEFAULT: ReadonlySet<ErrorCode> = new Set<ErrorCode>([\n ErrorCode.RateLimited,\n ErrorCode.Unavailable,\n ErrorCode.Timeout,\n]);\n\n/** Optional details attached to an SDK error. */\nexport interface ErrorDetails {\n /** HTTP status when the error came from a response. */\n httpStatus?: number;\n /** Vendor request id header when present. */\n requestId?: string;\n /** Overrides the default retryability of the code. */\n retryable?: boolean;\n /** Server-requested wait (from `Retry-After`) in milliseconds. */\n retryAfterMs?: number;\n /** Underlying error (already redacted). */\n cause?: unknown;\n}\n\n/**\n * Base class of every error thrown by the OIDC SDK.\n *\n * The message never contains credentials, request bodies or unfiltered response bodies.\n */\nexport class OidcError extends Error {\n /** Canonical error code. */\n readonly code: ErrorCode;\n /** HTTP status when the error came from a response. */\n readonly httpStatus?: number;\n /** Vendor request id when the response carried one. */\n readonly requestId?: string;\n /** Whether retrying the same call may succeed. */\n readonly retryable: boolean;\n /** Server-requested wait in milliseconds (rate limits, `Retry-After`). */\n readonly retryAfterMs?: number;\n\n constructor(code: ErrorCode, message: string, details: ErrorDetails = {}) {\n super(message, details.cause === undefined ? undefined : { cause: details.cause });\n this.name = new.target.name;\n this.code = code;\n this.retryable = details.retryable ?? RETRYABLE_BY_DEFAULT.has(code);\n if (details.httpStatus !== undefined) this.httpStatus = details.httpStatus;\n if (details.requestId !== undefined) this.requestId = details.requestId;\n if (details.retryAfterMs !== undefined) this.retryAfterMs = details.retryAfterMs;\n }\n\n /** JSON form (no stack, no cause). */\n toJSON(): Record<string, unknown> {\n const out: Record<string, unknown> = {\n name: this.name,\n code: this.code,\n message: this.message,\n retryable: this.retryable,\n };\n if (this.httpStatus !== undefined) out.httpStatus = this.httpStatus;\n if (this.requestId !== undefined) out.requestId = this.requestId;\n if (this.retryAfterMs !== undefined) out.retryAfterMs = this.retryAfterMs;\n return out;\n }\n}\n\n/** Invalid or missing configuration. */\nexport class ConfigError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Config, message, details);\n }\n}\n\n/** HTTP 401: missing or invalid credentials. */\nexport class AuthenticationError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Authentication, message, details);\n }\n}\n\n/** HTTP 403: the credentials do not allow the operation. */\nexport class PermissionDeniedError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.PermissionDenied, message, details);\n }\n}\n\n/** HTTP 404 or a missing record. */\nexport class NotFoundError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.NotFound, message, details);\n }\n}\n\n/** HTTP 409/412 or a compare-and-set mismatch. */\nexport class ConflictError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Conflict, message, details);\n }\n}\n\n/** HTTP 429. `retryAfterMs` is set when the server sent `Retry-After`. */\nexport class RateLimitError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.RateLimited, message, details);\n }\n}\n\n/** HTTP 400/413/422/other 4xx, or bad input caught client side. */\nexport class ValidationError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Validation, message, details);\n }\n}\n\n/** Network error or HTTP 500/502/503. */\nexport class UnavailableError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Unavailable, message, details);\n }\n}\n\n/** A connect, request or total deadline was exceeded, or HTTP 408/504. */\nexport class TimeoutError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Timeout, message, details);\n }\n}\n\n/** The service or deployment does not offer the capability (HTTP 501, missing API). */\nexport class UnsupportedError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Unsupported, message, details);\n }\n}\n\n/** The caller cancelled the operation (AbortSignal). */\nexport class CancelledError extends OidcError {\n constructor(message: string, details?: ErrorDetails) {\n super(ErrorCode.Cancelled, message, details);\n }\n}\n\ntype ErrorClass = new (message: string, details?: ErrorDetails) => OidcError;\n\nconst CLASS_BY_CODE: Record<ErrorCode, ErrorClass> = {\n CONFIG: ConfigError,\n AUTHENTICATION: AuthenticationError,\n PERMISSION_DENIED: PermissionDeniedError,\n NOT_FOUND: NotFoundError,\n CONFLICT: ConflictError,\n RATE_LIMITED: RateLimitError,\n VALIDATION: ValidationError,\n UNAVAILABLE: UnavailableError,\n TIMEOUT: TimeoutError,\n UNSUPPORTED: UnsupportedError,\n CANCELLED: CancelledError,\n};\n\nconst REASON_BY_CODE: Record<ErrorCode, string> = {\n CONFIG: \"invalid configuration\",\n AUTHENTICATION: \"authentication failed\",\n PERMISSION_DENIED: \"permission denied\",\n NOT_FOUND: \"not found\",\n CONFLICT: \"conflict\",\n RATE_LIMITED: \"rate limited\",\n VALIDATION: \"invalid request\",\n UNAVAILABLE: \"service unavailable\",\n TIMEOUT: \"timed out\",\n UNSUPPORTED: \"not supported\",\n CANCELLED: \"cancelled\",\n};\n\n/** Creates the subclass that matches `code`. */\nexport function errorForCode(\n code: ErrorCode,\n message: string,\n details?: ErrorDetails,\n): OidcError {\n return new CLASS_BY_CODE[code](message, details);\n}\n\n/** Default short reason for a code, used in messages such as `\"op: not found (HTTP 404)\"`. */\nexport function reasonForCode(code: ErrorCode): string {\n return REASON_BY_CODE[code];\n}\n\n/** Maps an HTTP status (>= 400) to its canonical {@link ErrorCode} (SPEC §2.1). */\nexport function codeForStatus(status: number): ErrorCode {\n switch (status) {\n case 401:\n return ErrorCode.Authentication;\n case 403:\n return ErrorCode.PermissionDenied;\n case 404:\n return ErrorCode.NotFound;\n case 409:\n case 412:\n return ErrorCode.Conflict;\n case 429:\n return ErrorCode.RateLimited;\n case 408:\n case 504:\n return ErrorCode.Timeout;\n case 501:\n return ErrorCode.Unsupported;\n default:\n return status >= 500 ? ErrorCode.Unavailable : ErrorCode.Validation;\n }\n}\n\n/** Builds the error for an HTTP error response: `\"<operation>: <reason> (HTTP <status>)\"`. */\nexport function errorForStatus(\n operation: string,\n status: number,\n details: Omit<ErrorDetails, \"httpStatus\"> & { reason?: string } = {},\n): OidcError {\n const code = codeForStatus(status);\n const { reason, ...rest } = details;\n const text = reason !== undefined && reason !== \"\" ? reason : reasonForCode(code);\n return errorForCode(code, `${operation}: ${text} (HTTP ${status})`, {\n ...rest,\n httpStatus: status,\n });\n}\n\n/** True when `err` is an SDK error (optionally with the given code). */\nexport function isOidcError(err: unknown, code?: ErrorCode): err is OidcError {\n return err instanceof OidcError && (code === undefined || err.code === code);\n}\n","// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\nimport { CancelledError } from \"./errors.js\";\n\n/** Throws {@link CancelledError} when the signal is already aborted. */\nexport function throwIfAborted(signal: AbortSignal | undefined, operation: string): void {\n if (signal?.aborted === true) throw new CancelledError(`${operation}: cancelled`);\n}\n\n/**\n * Resolves after `ms` milliseconds; rejects with {@link CancelledError} when `signal` aborts\n * first. The timer does not keep the process alive.\n */\nexport function sleep(ms: number, signal?: AbortSignal, operation = \"sleep\"): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (signal?.aborted === true) {\n reject(new CancelledError(`${operation}: cancelled`));\n return;\n }\n const onAbort = (): void => {\n clearTimeout(timer);\n reject(new CancelledError(`${operation}: cancelled`));\n };\n const timer = setTimeout(\n () => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n },\n Math.max(0, ms),\n );\n timer.unref();\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n","// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\nimport { sleep as defaultSleep, throwIfAborted } from \"./abort.js\";\nimport { TimeoutError } from \"./errors.js\";\n\n/** Options of {@link pollUntil}. */\nexport interface PollOptions {\n /** Give up after this many ms (default 30 000). */\n timeoutMs?: number;\n /** Wait between attempts in ms (default 1 000). */\n intervalMs?: number;\n /** Caller cancellation. */\n signal?: AbortSignal;\n /** Name used in the timeout message (default `\"poll\"`). */\n operation?: string;\n /** Errors for which polling continues instead of failing (default: none). */\n ignoreError?: (error: unknown) => boolean;\n /** Test seam. */\n sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;\n /** Test seam: clock in ms. */\n now?: () => number;\n}\n\n/**\n * Calls `fn` until `predicate(value)` is true and returns that value. Throws\n * {@link TimeoutError} when the time budget runs out (the message includes the last value's\n * failure reason when the predicate never matched) and `CancelledError` on abort.\n */\nexport async function pollUntil<T>(\n fn: (attempt: number) => Promise<T>,\n predicate: (value: T) => boolean,\n options: PollOptions = {},\n): Promise<T> {\n const timeoutMs = options.timeoutMs ?? 30_000;\n const intervalMs = options.intervalMs ?? 1_000;\n const operation = options.operation ?? \"poll\";\n const sleep = options.sleep ?? defaultSleep;\n const now = options.now ?? Date.now;\n const deadline = now() + timeoutMs;\n let lastError: unknown;\n for (let attempt = 1; ; attempt++) {\n throwIfAborted(options.signal, operation);\n try {\n const value = await fn(attempt);\n if (predicate(value)) return value;\n } catch (err) {\n if (options.ignoreError?.(err) !== true) throw err;\n lastError = err;\n }\n const remaining = deadline - now();\n if (remaining <= 0) {\n throw new TimeoutError(\n `${operation}: condition not met within ${timeoutMs} ms after ${attempt} attempts`,\n lastError === undefined ? {} : { cause: lastError },\n );\n }\n await sleep(Math.min(intervalMs, remaining), options.signal);\n }\n}\n"]}
|