@productcraft/heimdall 0.1.0 → 0.2.1
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/README.md +38 -20
- package/dist/index.cjs +69 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -65
- package/dist/index.d.ts +123 -65
- package/dist/index.js +69 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1260,13 +1260,13 @@ type SetScopesDto = {
|
|
|
1260
1260
|
|
|
1261
1261
|
type AppControllerListInvitesQueryParams = {
|
|
1262
1262
|
/**
|
|
1263
|
-
* @type string
|
|
1263
|
+
* @type string | undefined
|
|
1264
1264
|
*/
|
|
1265
|
-
limit
|
|
1265
|
+
limit?: string;
|
|
1266
1266
|
/**
|
|
1267
|
-
* @type string
|
|
1267
|
+
* @type string | undefined
|
|
1268
1268
|
*/
|
|
1269
|
-
cursor
|
|
1269
|
+
cursor?: string;
|
|
1270
1270
|
};
|
|
1271
1271
|
|
|
1272
1272
|
/**
|
|
@@ -1276,13 +1276,13 @@ type AppControllerListInvitesQueryParams = {
|
|
|
1276
1276
|
|
|
1277
1277
|
type AppControllerListMembersQueryParams = {
|
|
1278
1278
|
/**
|
|
1279
|
-
* @type string
|
|
1279
|
+
* @type string | undefined
|
|
1280
1280
|
*/
|
|
1281
|
-
limit
|
|
1281
|
+
limit?: string;
|
|
1282
1282
|
/**
|
|
1283
|
-
* @type string
|
|
1283
|
+
* @type string | undefined
|
|
1284
1284
|
*/
|
|
1285
|
-
cursor
|
|
1285
|
+
cursor?: string;
|
|
1286
1286
|
};
|
|
1287
1287
|
|
|
1288
1288
|
/**
|
|
@@ -1292,21 +1292,21 @@ type AppControllerListMembersQueryParams = {
|
|
|
1292
1292
|
|
|
1293
1293
|
type EndUserControllerListEndUsersQueryParams = {
|
|
1294
1294
|
/**
|
|
1295
|
-
* @type string
|
|
1295
|
+
* @type string | undefined
|
|
1296
1296
|
*/
|
|
1297
|
-
limit
|
|
1297
|
+
limit?: string;
|
|
1298
1298
|
/**
|
|
1299
|
-
* @type string
|
|
1299
|
+
* @type string | undefined
|
|
1300
1300
|
*/
|
|
1301
|
-
cursor
|
|
1301
|
+
cursor?: string;
|
|
1302
1302
|
/**
|
|
1303
|
-
* @type string
|
|
1303
|
+
* @type string | undefined
|
|
1304
1304
|
*/
|
|
1305
|
-
status
|
|
1305
|
+
status?: string;
|
|
1306
1306
|
/**
|
|
1307
|
-
* @type string
|
|
1307
|
+
* @type string | undefined
|
|
1308
1308
|
*/
|
|
1309
|
-
search
|
|
1309
|
+
search?: string;
|
|
1310
1310
|
};
|
|
1311
1311
|
|
|
1312
1312
|
/**
|
|
@@ -1316,21 +1316,21 @@ type EndUserControllerListEndUsersQueryParams = {
|
|
|
1316
1316
|
|
|
1317
1317
|
type AppAuditControllerGetAuditLogsQueryParams = {
|
|
1318
1318
|
/**
|
|
1319
|
-
* @type string
|
|
1319
|
+
* @type string | undefined
|
|
1320
1320
|
*/
|
|
1321
|
-
limit
|
|
1321
|
+
limit?: string;
|
|
1322
1322
|
/**
|
|
1323
|
-
* @type string
|
|
1323
|
+
* @type string | undefined
|
|
1324
1324
|
*/
|
|
1325
|
-
cursor
|
|
1325
|
+
cursor?: string;
|
|
1326
1326
|
/**
|
|
1327
|
-
* @type string
|
|
1327
|
+
* @type string | undefined
|
|
1328
1328
|
*/
|
|
1329
|
-
action
|
|
1329
|
+
action?: string;
|
|
1330
1330
|
/**
|
|
1331
|
-
* @type string
|
|
1331
|
+
* @type string | undefined
|
|
1332
1332
|
*/
|
|
1333
|
-
actor_id
|
|
1333
|
+
actor_id?: string;
|
|
1334
1334
|
};
|
|
1335
1335
|
|
|
1336
1336
|
/**
|
|
@@ -1340,13 +1340,13 @@ type AppAuditControllerGetAuditLogsQueryParams = {
|
|
|
1340
1340
|
|
|
1341
1341
|
type M2MControllerListClientsQueryParams = {
|
|
1342
1342
|
/**
|
|
1343
|
-
* @type string
|
|
1343
|
+
* @type string | undefined
|
|
1344
1344
|
*/
|
|
1345
|
-
limit
|
|
1345
|
+
limit?: string;
|
|
1346
1346
|
/**
|
|
1347
|
-
* @type string
|
|
1347
|
+
* @type string | undefined
|
|
1348
1348
|
*/
|
|
1349
|
-
cursor
|
|
1349
|
+
cursor?: string;
|
|
1350
1350
|
};
|
|
1351
1351
|
|
|
1352
1352
|
/**
|
|
@@ -1356,13 +1356,13 @@ type M2MControllerListClientsQueryParams = {
|
|
|
1356
1356
|
|
|
1357
1357
|
type RoleControllerListRolesQueryParams = {
|
|
1358
1358
|
/**
|
|
1359
|
-
* @type string
|
|
1359
|
+
* @type string | undefined
|
|
1360
1360
|
*/
|
|
1361
|
-
limit
|
|
1361
|
+
limit?: string;
|
|
1362
1362
|
/**
|
|
1363
|
-
* @type string
|
|
1363
|
+
* @type string | undefined
|
|
1364
1364
|
*/
|
|
1365
|
-
cursor
|
|
1365
|
+
cursor?: string;
|
|
1366
1366
|
};
|
|
1367
1367
|
|
|
1368
1368
|
declare class AppScope {
|
|
@@ -1477,6 +1477,11 @@ type AuthorizeBatchResultDto = {
|
|
|
1477
1477
|
* @type boolean
|
|
1478
1478
|
*/
|
|
1479
1479
|
authorized: boolean;
|
|
1480
|
+
/**
|
|
1481
|
+
* @description Caller-supplied id from the corresponding check entry. Echoed back so callers can correlate results to inputs without relying on array order.
|
|
1482
|
+
* @type string | undefined
|
|
1483
|
+
*/
|
|
1484
|
+
id?: string;
|
|
1480
1485
|
/**
|
|
1481
1486
|
* @type array
|
|
1482
1487
|
*/
|
|
@@ -1798,10 +1803,10 @@ type UpdateMeDto = {
|
|
|
1798
1803
|
*/
|
|
1799
1804
|
type VerifyBody = {
|
|
1800
1805
|
/**
|
|
1801
|
-
* @description EndUser or M2M JWT to verify against the app JWKS.
|
|
1802
|
-
* @type string
|
|
1806
|
+
* @description EndUser or M2M JWT to verify against the app JWKS. Optional — if omitted, the token is read from the `Authorization: Bearer <jwt>` header instead.
|
|
1807
|
+
* @type string | undefined
|
|
1803
1808
|
*/
|
|
1804
|
-
token
|
|
1809
|
+
token?: string;
|
|
1805
1810
|
};
|
|
1806
1811
|
|
|
1807
1812
|
/**
|
|
@@ -1820,10 +1825,10 @@ type AuthorizeBody = {
|
|
|
1820
1825
|
*/
|
|
1821
1826
|
permissions?: string[];
|
|
1822
1827
|
/**
|
|
1823
|
-
* @description JWT to verify and authorize.
|
|
1824
|
-
* @type string
|
|
1828
|
+
* @description JWT to verify and authorize. Optional — if omitted, the token is read from the `Authorization: Bearer <jwt>` header.
|
|
1829
|
+
* @type string | undefined
|
|
1825
1830
|
*/
|
|
1826
|
-
token
|
|
1831
|
+
token?: string;
|
|
1827
1832
|
};
|
|
1828
1833
|
|
|
1829
1834
|
/**
|
|
@@ -1832,10 +1837,20 @@ type AuthorizeBody = {
|
|
|
1832
1837
|
*/
|
|
1833
1838
|
type AuthorizeBatchEntry = {
|
|
1834
1839
|
/**
|
|
1835
|
-
* @description
|
|
1836
|
-
* @type
|
|
1840
|
+
* @description Caller-chosen correlation id for this check. Echoed back on the matching result so the caller can map results to inputs without relying on array order.
|
|
1841
|
+
* @type string | undefined
|
|
1837
1842
|
*/
|
|
1838
|
-
|
|
1843
|
+
id?: string;
|
|
1844
|
+
/**
|
|
1845
|
+
* @description Single permission to check, e.g. \'invoice.read\'. Use this OR `permissions`.
|
|
1846
|
+
* @type string | undefined
|
|
1847
|
+
*/
|
|
1848
|
+
permission?: string;
|
|
1849
|
+
/**
|
|
1850
|
+
* @description Multiple permissions; ALL must be held for this check to pass.
|
|
1851
|
+
* @type array | undefined
|
|
1852
|
+
*/
|
|
1853
|
+
permissions?: string[];
|
|
1839
1854
|
};
|
|
1840
1855
|
|
|
1841
1856
|
/**
|
|
@@ -1845,15 +1860,15 @@ type AuthorizeBatchEntry = {
|
|
|
1845
1860
|
|
|
1846
1861
|
type AuthorizeBatchBody = {
|
|
1847
1862
|
/**
|
|
1848
|
-
* @description List of checks. Each returns { authorized, missing_permissions }.
|
|
1863
|
+
* @description List of checks. Each returns { id?, authorized, missing_permissions }.
|
|
1849
1864
|
* @type array
|
|
1850
1865
|
*/
|
|
1851
1866
|
checks: AuthorizeBatchEntry[];
|
|
1852
1867
|
/**
|
|
1853
|
-
* @description JWT to verify and authorize against each check.
|
|
1854
|
-
* @type string
|
|
1868
|
+
* @description JWT to verify and authorize against each check. Optional — if omitted, the token is read from the `Authorization: Bearer <jwt>` header.
|
|
1869
|
+
* @type string | undefined
|
|
1855
1870
|
*/
|
|
1856
|
-
token
|
|
1871
|
+
token?: string;
|
|
1857
1872
|
};
|
|
1858
1873
|
|
|
1859
1874
|
/**
|
|
@@ -2077,6 +2092,15 @@ interface VerifyOptions {
|
|
|
2077
2092
|
*/
|
|
2078
2093
|
declare function verifyHeimdallToken(token: string, getKey: HeimdallGetKeyFn, opts?: VerifyOptions): Promise<HeimdallClaims>;
|
|
2079
2094
|
|
|
2095
|
+
/**
|
|
2096
|
+
* Legacy `iss` claim Heimdall Consumer-API tokens used to be minted
|
|
2097
|
+
* with. Kept exported so consumers verifying tokens issued before the
|
|
2098
|
+
* 2026-05-24 per-app-issuer migration can still match `iss` while a
|
|
2099
|
+
* deployment cycles to fresh tokens. New tokens carry the per-app
|
|
2100
|
+
* issuer URL — `${baseUrl}/${appSlug}` — accessible via
|
|
2101
|
+
* `scope.expectedIssuer`.
|
|
2102
|
+
*/
|
|
2103
|
+
declare const HEIMDALL_LEGACY_ISSUER = "heimdall";
|
|
2080
2104
|
interface ConsumerScopeInternals {
|
|
2081
2105
|
client: Client;
|
|
2082
2106
|
baseUrl: string;
|
|
@@ -2086,15 +2110,38 @@ interface ConsumerScopeInternals {
|
|
|
2086
2110
|
declare class ConsumerScope {
|
|
2087
2111
|
/** The appSlug bound to this scope. */
|
|
2088
2112
|
readonly appSlug: string;
|
|
2089
|
-
/**
|
|
2113
|
+
/**
|
|
2114
|
+
* Issuer the Heimdall Consumer API stamps on every token for this
|
|
2115
|
+
* app — the public Heimdall API base joined with the app slug
|
|
2116
|
+
* (e.g. `https://api.heimdall.productcraft.co/acme`). Pin it in
|
|
2117
|
+
* your local verifier so a token minted for another app on the
|
|
2118
|
+
* platform cannot pass.
|
|
2119
|
+
*
|
|
2120
|
+
* `scope.verifyToken` already enforces this for you. Pass it as a
|
|
2121
|
+
* second-position issuer if you're wiring `jose.jwtVerify`,
|
|
2122
|
+
* `passport-jwt`, or PyJWT yourself.
|
|
2123
|
+
*/
|
|
2090
2124
|
readonly expectedIssuer: string;
|
|
2091
|
-
/**
|
|
2092
|
-
|
|
2125
|
+
/**
|
|
2126
|
+
* Audience the Consumer API stamps on every token for this app —
|
|
2127
|
+
* literally the app slug (e.g. `"acme"`). Pin it in your verifier
|
|
2128
|
+
* the same way as `expectedIssuer`. `scope.verifyToken` enforces
|
|
2129
|
+
* it by default.
|
|
2130
|
+
*/
|
|
2131
|
+
readonly expectedAudience: string;
|
|
2132
|
+
/**
|
|
2133
|
+
* Both accepted issuer strings (`expectedIssuer` + the legacy
|
|
2134
|
+
* `'heimdall'` literal). `verifyToken` passes this to jose so tokens
|
|
2135
|
+
* minted before the 2026-05-24 per-app-issuer migration keep
|
|
2136
|
+
* verifying alongside fresh ones — useful for the ~1-hour transition
|
|
2137
|
+
* window per access-token TTL, and the longer session TTL on
|
|
2138
|
+
* refresh tokens.
|
|
2139
|
+
*/
|
|
2140
|
+
readonly acceptedIssuers: readonly string[];
|
|
2093
2141
|
/** jose-compatible JWKS resolver. Drop into `jose.jwtVerify`, passport-jwt, etc. */
|
|
2094
2142
|
readonly jwks: JwksCache;
|
|
2095
2143
|
private readonly client;
|
|
2096
2144
|
constructor(appSlug: string, internals: ConsumerScopeInternals, opts?: {
|
|
2097
|
-
audience?: string;
|
|
2098
2145
|
jwksTtlMs?: number;
|
|
2099
2146
|
});
|
|
2100
2147
|
/**
|
|
@@ -2103,7 +2150,17 @@ declare class ConsumerScope {
|
|
|
2103
2150
|
* upstream; remove once the spec is fixed.
|
|
2104
2151
|
*/
|
|
2105
2152
|
private callDirect;
|
|
2106
|
-
/**
|
|
2153
|
+
/**
|
|
2154
|
+
* Verify a Heimdall-issued JWT against this app's JWKS.
|
|
2155
|
+
*
|
|
2156
|
+
* Checks the signature, expiry, `iss`, and `aud`. Accepts both the
|
|
2157
|
+
* per-app issuer URL (`expectedIssuer`) and the legacy `'heimdall'`
|
|
2158
|
+
* literal during the issuer-migration transition window — callers
|
|
2159
|
+
* who want to refuse legacy tokens can override with
|
|
2160
|
+
* `{ issuer: scope.expectedIssuer }`. Audience defaults to the app
|
|
2161
|
+
* slug (`expectedAudience`); pass `{ audience: false }` (in an
|
|
2162
|
+
* options override) to skip the audience check entirely.
|
|
2163
|
+
*/
|
|
2107
2164
|
verifyToken(token: string, opts?: VerifyOptions): Promise<HeimdallClaims>;
|
|
2108
2165
|
readonly auth: {
|
|
2109
2166
|
signin: (data: ConsumerSigninDto) => Promise<ConsumerAuthControllerSignin200>;
|
|
@@ -2170,6 +2227,13 @@ declare class ConsumerScope {
|
|
|
2170
2227
|
deleteAccount: () => Promise<void>;
|
|
2171
2228
|
};
|
|
2172
2229
|
readonly verify: {
|
|
2230
|
+
/**
|
|
2231
|
+
* The kubb-generated client makes `headers.authorization` a required
|
|
2232
|
+
* arg because the server controllers accept the bearer as a fallback
|
|
2233
|
+
* to `body.token`. We stub an empty string here — the HTTP client's
|
|
2234
|
+
* auth middleware overrides whatever's passed with the configured
|
|
2235
|
+
* credential (`PCAuth.apiKey` / `bearer` / `cookie`).
|
|
2236
|
+
*/
|
|
2173
2237
|
verify: (data: VerifyBody) => Promise<VerifyResponseDto>;
|
|
2174
2238
|
authorize: (data: AuthorizeBody) => Promise<AuthorizeResponseDto>;
|
|
2175
2239
|
authorizeBatch: (data: AuthorizeBatchBody) => Promise<AuthorizeBatchResponseDto>;
|
|
@@ -2224,17 +2288,17 @@ type AcceptInviteDto = {
|
|
|
2224
2288
|
|
|
2225
2289
|
type AppControllerListMyAppsQueryParams = {
|
|
2226
2290
|
/**
|
|
2227
|
-
* @type string
|
|
2291
|
+
* @type string | undefined
|
|
2228
2292
|
*/
|
|
2229
|
-
limit
|
|
2293
|
+
limit?: string;
|
|
2230
2294
|
/**
|
|
2231
|
-
* @type string
|
|
2295
|
+
* @type string | undefined
|
|
2232
2296
|
*/
|
|
2233
|
-
cursor
|
|
2297
|
+
cursor?: string;
|
|
2234
2298
|
/**
|
|
2235
|
-
* @type string
|
|
2299
|
+
* @type string | undefined
|
|
2236
2300
|
*/
|
|
2237
|
-
workspace_id
|
|
2301
|
+
workspace_id?: string;
|
|
2238
2302
|
};
|
|
2239
2303
|
|
|
2240
2304
|
/**
|
|
@@ -2244,9 +2308,9 @@ type AppControllerListMyAppsQueryParams = {
|
|
|
2244
2308
|
|
|
2245
2309
|
type StatsControllerGetMyStatsQueryParams = {
|
|
2246
2310
|
/**
|
|
2247
|
-
* @type string
|
|
2311
|
+
* @type string | undefined
|
|
2248
2312
|
*/
|
|
2249
|
-
workspace_id
|
|
2313
|
+
workspace_id?: string;
|
|
2250
2314
|
};
|
|
2251
2315
|
|
|
2252
2316
|
/**
|
|
@@ -2306,12 +2370,6 @@ declare class JwksFetchError extends JwtVerifyError {
|
|
|
2306
2370
|
}
|
|
2307
2371
|
|
|
2308
2372
|
interface HeimdallConfig extends PCClientConfig {
|
|
2309
|
-
/**
|
|
2310
|
-
* Override the default `audience` claim expected on tokens verified
|
|
2311
|
-
* via `consumer(slug).verifyToken(...)`. Per-call override is also
|
|
2312
|
-
* available on `verifyToken`'s options.
|
|
2313
|
-
*/
|
|
2314
|
-
expectedAudience?: string;
|
|
2315
2373
|
/** Per-app JWKS cache lifetime in ms. Default 10 minutes. */
|
|
2316
2374
|
jwksTtlMs?: number;
|
|
2317
2375
|
}
|
|
@@ -2351,4 +2409,4 @@ declare class Heimdall {
|
|
|
2351
2409
|
};
|
|
2352
2410
|
}
|
|
2353
2411
|
|
|
2354
|
-
export { type AcceptInviteDto, AppScope, type AssignRoleDto, type AuthorizeBatchBody, type AuthorizeBody, type ClientCredentialsDto, type ConsumerLogoutDto, type ConsumerRefreshDto, type ConsumerRequestPasswordResetDto, type ConsumerResetPasswordDto, ConsumerScope, type ConsumerSigninDto, type ConsumerSignupDto, type ConsumerTokenResponseDto, type CreateApiKeyDto, type CreateAppDto, type CreateInviteDto, type CreateM2MClientDto, type CreatePermissionDto, type CreateRoleDto, Heimdall, type HeimdallClaims, type HeimdallConfig, HeimdallHttpError, type IdpNativeSigninDto, type IdpNativeUserHintDto, type IdpTokenResponseDto, JwksCache, JwksFetchError, JwksKeyNotFoundError, JwtAudienceMismatchError, JwtExpiredError, JwtInvalidError, JwtIssuerMismatchError, JwtNotYetValidError, JwtVerifyError, type SetPermissionsDto, type SetScopesDto, type UpdateAppDto, type UpdateAppStatusDto, type UpdateAuthConfigDto, type UpdateEndUserDto, type UpdateEndUserRoleDto, type UpdateEndUserStatusDto, type UpdateM2MClientDto, type UpdateMeDto, type UpdateRoleDto, type VerifyBody, type VerifyOptions, verifyHeimdallToken };
|
|
2412
|
+
export { type AcceptInviteDto, AppScope, type AssignRoleDto, type AuthorizeBatchBody, type AuthorizeBody, type ClientCredentialsDto, type ConsumerLogoutDto, type ConsumerRefreshDto, type ConsumerRequestPasswordResetDto, type ConsumerResetPasswordDto, ConsumerScope, type ConsumerSigninDto, type ConsumerSignupDto, type ConsumerTokenResponseDto, type CreateApiKeyDto, type CreateAppDto, type CreateInviteDto, type CreateM2MClientDto, type CreatePermissionDto, type CreateRoleDto, HEIMDALL_LEGACY_ISSUER, Heimdall, type HeimdallClaims, type HeimdallConfig, HeimdallHttpError, type IdpNativeSigninDto, type IdpNativeUserHintDto, type IdpTokenResponseDto, JwksCache, JwksFetchError, JwksKeyNotFoundError, JwtAudienceMismatchError, JwtExpiredError, JwtInvalidError, JwtIssuerMismatchError, JwtNotYetValidError, JwtVerifyError, type SetPermissionsDto, type SetScopesDto, type UpdateAppDto, type UpdateAppStatusDto, type UpdateAuthConfigDto, type UpdateEndUserDto, type UpdateEndUserRoleDto, type UpdateEndUserStatusDto, type UpdateM2MClientDto, type UpdateMeDto, type UpdateRoleDto, type VerifyBody, type VerifyOptions, verifyHeimdallToken };
|