@atlasauth/backend 0.15.0 → 0.16.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/botid.d.ts +70 -0
  3. package/dist/botid.js +88 -0
  4. package/dist/botid.js.map +1 -0
  5. package/dist/client/action-gallery.d.ts +215 -0
  6. package/dist/client/action-gallery.js +66 -0
  7. package/dist/client/action-gallery.js.map +1 -0
  8. package/dist/client/actions.d.ts +21 -0
  9. package/dist/client/actions.js.map +1 -1
  10. package/dist/client/attack-protection.d.ts +33 -1
  11. package/dist/client/attack-protection.js.map +1 -1
  12. package/dist/client/billing-plans.d.ts +93 -0
  13. package/dist/client/billing-plans.js +31 -0
  14. package/dist/client/billing-plans.js.map +1 -1
  15. package/dist/client/custom-oauth-providers.d.ts +243 -0
  16. package/dist/client/custom-oauth-providers.js +60 -0
  17. package/dist/client/custom-oauth-providers.js.map +1 -0
  18. package/dist/client/email-templates.d.ts +1 -1
  19. package/dist/client/email-templates.js.map +1 -1
  20. package/dist/client/index.d.ts +108 -0
  21. package/dist/client/index.js +7 -0
  22. package/dist/client/index.js.map +1 -1
  23. package/dist/client/instance-security.d.ts +70 -0
  24. package/dist/client/instance-security.js +20 -0
  25. package/dist/client/instance-security.js.map +1 -1
  26. package/dist/client/oauth-clients.d.ts +29 -2
  27. package/dist/client/oauth-clients.js.map +1 -1
  28. package/dist/client/resource-servers.d.ts +22 -2
  29. package/dist/client/resource-servers.js.map +1 -1
  30. package/dist/client/risk-based-mfa.d.ts +3 -0
  31. package/dist/client/risk-based-mfa.js.map +1 -1
  32. package/dist/client/sessions.d.ts +16 -0
  33. package/dist/client/sessions.js +15 -0
  34. package/dist/client/sessions.js.map +1 -1
  35. package/dist/client/sso-connections.d.ts +83 -0
  36. package/dist/client/sso-connections.js +29 -0
  37. package/dist/client/sso-connections.js.map +1 -1
  38. package/dist/index.d.ts +3 -2
  39. package/dist/index.js +6 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/oauth-resource.d.ts +81 -1
  42. package/dist/oauth-resource.js +204 -29
  43. package/dist/oauth-resource.js.map +1 -1
  44. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  import { type RequestFn } from './request';
2
2
  import type { ListPage } from './types';
3
+ import { type IdpInitiatedLoginSettings, type ProfileMapping, type ProfileMappingPreview, type ProfileMappingPreviewBody, type TokenEndpointAuthMethod, type UpstreamLogoutSettings, type UpstreamUrls } from './custom-oauth-providers';
3
4
  export interface ClaimRoleMapping {
4
5
  claim: string;
5
6
  value: string;
@@ -22,6 +23,21 @@ export interface SsoConnection {
22
23
  saml_allow_idp_initiated: boolean;
23
24
  saml_sign_authn_requests: boolean;
24
25
  saml_want_response_signed: boolean;
26
+ /** SAML Single Logout is on for the connection. */
27
+ saml_single_logout?: boolean;
28
+ /** The IdP SingleLogoutService Location / ResponseLocation and delivery binding. */
29
+ saml_idp_slo_url?: string | null;
30
+ saml_idp_slo_response_url?: string | null;
31
+ saml_idp_slo_binding?: 'redirect' | 'post';
32
+ /** The IdP SOAP SingleLogoutService — the back channel for sessions ended server-side. */
33
+ saml_idp_slo_soap_url?: string | null;
34
+ /** Assertions that are not encrypted to the connection's key are refused. */
35
+ saml_require_encrypted_assertions?: boolean;
36
+ /** An SP encryption key pair is set up (the private key is never returned). */
37
+ has_saml_encryption_key?: boolean;
38
+ /** A key rotation is in progress (the previous key is still accepted). */
39
+ has_previous_saml_encryption_key?: boolean;
40
+ saml_encryption_rotated_at?: number | null;
25
41
  has_discourse_secret: boolean;
26
42
  discourse_provider_url: string | null;
27
43
  allowed_domains: string[];
@@ -31,6 +47,14 @@ export interface SsoConnection {
31
47
  attribute_mapping?: SsoAttributeMapping;
32
48
  /** OIDC: extra scopes requested on top of openid email profile. */
33
49
  oidc_scopes?: string[];
50
+ /** OIDC relying-party settings (see custom OAuth providers). */
51
+ profile_mapping?: Required<ProfileMapping> | null;
52
+ token_endpoint_auth_method?: TokenEndpointAuthMethod | null;
53
+ client_assertion_audience?: string | null;
54
+ logout?: Required<UpstreamLogoutSettings>;
55
+ idp_initiated_login?: Required<IdpInitiatedLoginSettings>;
56
+ /** OIDC connections: the URLs to register at the IdP. */
57
+ upstream_urls?: UpstreamUrls | null;
34
58
  /** Routing domains of an org-owned connection that the org has not verified. */
35
59
  domain_warnings?: Array<{
36
60
  domain: string;
@@ -43,9 +67,23 @@ export interface SamlMetadata {
43
67
  object: 'sso_saml_metadata';
44
68
  sp_entity_id: string;
45
69
  acs_url: string;
70
+ /** Our SingleLogoutService URL (both bindings), when Single Logout is on. */
71
+ slo_url?: string | null;
46
72
  /** The SP EntityDescriptor XML, carried as a string inside this JSON envelope. */
47
73
  metadata_xml: string;
48
74
  }
75
+ /** A SAML connection's SP encryption key pair — certificates only. */
76
+ export interface SamlEncryptionKey {
77
+ object: 'sso_saml_encryption_key';
78
+ connection_id: string;
79
+ /** The current certificate (PEM), published in SP metadata; null when encryption is off. */
80
+ certificate: string | null;
81
+ /** The previous certificate during a rotation; null otherwise. */
82
+ previous_certificate: string | null;
83
+ /** When the current key was installed (epoch ms). */
84
+ rotated_at: number | null;
85
+ require_encrypted_assertions: boolean;
86
+ }
49
87
  export interface CreateSsoConnectionBody {
50
88
  organization_id?: string | null;
51
89
  type?: 'oidc' | 'saml' | 'discourse' | 'discourse_consumer';
@@ -62,6 +100,16 @@ export interface CreateSsoConnectionBody {
62
100
  saml_allow_idp_initiated?: boolean;
63
101
  saml_sign_authn_requests?: boolean;
64
102
  saml_want_response_signed?: boolean;
103
+ /** SAML Single Logout on/off. */
104
+ saml_single_logout?: boolean;
105
+ /** https; null clears it. Filled by IdP metadata import when published. */
106
+ saml_idp_slo_url?: string | null;
107
+ saml_idp_slo_response_url?: string | null;
108
+ saml_idp_slo_binding?: 'redirect' | 'post' | null;
109
+ /** https; null clears it. The back channel for sessions ended server-side. */
110
+ saml_idp_slo_soap_url?: string | null;
111
+ /** Requires an encryption key (see `createSamlEncryptionKey`). */
112
+ saml_require_encrypted_assertions?: boolean;
65
113
  discourse_secret?: string;
66
114
  discourse_provider_url?: string;
67
115
  allowed_domains?: string[];
@@ -71,6 +119,15 @@ export interface CreateSsoConnectionBody {
71
119
  attribute_mapping?: SsoAttributeMapping | null;
72
120
  /** OIDC only; null clears them. */
73
121
  oidc_scopes?: string[] | null;
122
+ /** OIDC: declarative profile mapping; null clears it. */
123
+ profile_mapping?: ProfileMapping | null;
124
+ /** OIDC: token-endpoint client authentication (private_key_jwt needs no secret). */
125
+ token_endpoint_auth_method?: TokenEndpointAuthMethod | null;
126
+ client_assertion_audience?: string | null;
127
+ /** OIDC: RP-initiated and back-channel logout. */
128
+ logout?: UpstreamLogoutSettings | null;
129
+ /** OIDC: third-party initiated login. */
130
+ idp_initiated_login?: IdpInitiatedLoginSettings | null;
74
131
  }
75
132
  /** Claim (OIDC) or attribute (SAML) names for each profile field. */
76
133
  export interface SsoAttributeMapping {
@@ -93,6 +150,32 @@ export declare function ssoConnectionsResource(request: RequestFn): {
93
150
  id: string;
94
151
  deleted: true;
95
152
  }>;
153
+ /** OIDC: run the connection's profile mapping (or the body's) against a pasted sample. */
154
+ previewProfileMapping(id: string, body: ProfileMappingPreviewBody): Promise<ProfileMappingPreview>;
155
+ /** OIDC: the connection's private_key_jwt signing keys. */
156
+ signingKeys(id: string): {
157
+ list(): Promise<ListPage<import("./custom-oauth-providers").UpstreamSigningKey>>;
158
+ rotate(body?: {
159
+ alg?: "RS256" | "PS256" | "ES256";
160
+ }, idempotencyKey?: string): Promise<import("./custom-oauth-providers").UpstreamSigningKey>;
161
+ retire(kid: string): Promise<{
162
+ object: "upstream_signing_key";
163
+ kid: string;
164
+ status: "retired";
165
+ }>;
166
+ };
96
167
  /** SP SAML metadata for a connection (JSON envelope carrying the XML). */
97
168
  samlMetadata(id: string): Promise<SamlMetadata>;
169
+ /** The SAML connection's SP encryption certificate(s). */
170
+ getSamlEncryptionKey(id: string): Promise<SamlEncryptionKey>;
171
+ /**
172
+ * Generate the SP encryption key pair, or ROTATE it when one exists: the
173
+ * current pair becomes the previous one (still advertised and accepted until
174
+ * {@link retirePreviousSamlEncryptionKey}).
175
+ */
176
+ createSamlEncryptionKey(id: string, idempotencyKey?: string): Promise<SamlEncryptionKey>;
177
+ /** Finish a rotation: stop accepting the previous encryption key. */
178
+ retirePreviousSamlEncryptionKey(id: string): Promise<SamlEncryptionKey>;
179
+ /** Turn assertion encryption off (refused while encrypted assertions are required). */
180
+ deleteSamlEncryptionKey(id: string): Promise<SamlEncryptionKey>;
98
181
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ssoConnectionsResource = ssoConnectionsResource;
4
4
  const request_1 = require("./request");
5
+ const custom_oauth_providers_1 = require("./custom-oauth-providers");
5
6
  function ssoConnectionsResource(request) {
6
7
  return {
7
8
  list() {
@@ -19,10 +20,38 @@ function ssoConnectionsResource(request) {
19
20
  delete(id) {
20
21
  return request({ method: 'DELETE', path: `/v1/sso_connections/${(0, request_1.enc)(id)}` });
21
22
  },
23
+ /** OIDC: run the connection's profile mapping (or the body's) against a pasted sample. */
24
+ previewProfileMapping(id, body) {
25
+ return request({ method: 'POST', path: `/v1/sso_connections/${(0, request_1.enc)(id)}/profile_mapping/preview`, body });
26
+ },
27
+ /** OIDC: the connection's private_key_jwt signing keys. */
28
+ signingKeys(id) {
29
+ return (0, custom_oauth_providers_1.upstreamSigningKeys)(request, `/v1/sso_connections/${(0, request_1.enc)(id)}`);
30
+ },
22
31
  /** SP SAML metadata for a connection (JSON envelope carrying the XML). */
23
32
  samlMetadata(id) {
24
33
  return request({ method: 'GET', path: `/v1/sso_connections/${(0, request_1.enc)(id)}/saml_metadata` });
25
34
  },
35
+ /** The SAML connection's SP encryption certificate(s). */
36
+ getSamlEncryptionKey(id) {
37
+ return request({ method: 'GET', path: `/v1/sso_connections/${(0, request_1.enc)(id)}/saml_encryption_key` });
38
+ },
39
+ /**
40
+ * Generate the SP encryption key pair, or ROTATE it when one exists: the
41
+ * current pair becomes the previous one (still advertised and accepted until
42
+ * {@link retirePreviousSamlEncryptionKey}).
43
+ */
44
+ createSamlEncryptionKey(id, idempotencyKey) {
45
+ return request({ method: 'POST', path: `/v1/sso_connections/${(0, request_1.enc)(id)}/saml_encryption_key`, idempotencyKey });
46
+ },
47
+ /** Finish a rotation: stop accepting the previous encryption key. */
48
+ retirePreviousSamlEncryptionKey(id) {
49
+ return request({ method: 'DELETE', path: `/v1/sso_connections/${(0, request_1.enc)(id)}/saml_encryption_key/previous` });
50
+ },
51
+ /** Turn assertion encryption off (refused while encrypted assertions are required). */
52
+ deleteSamlEncryptionKey(id) {
53
+ return request({ method: 'DELETE', path: `/v1/sso_connections/${(0, request_1.enc)(id)}/saml_encryption_key` });
54
+ },
26
55
  };
27
56
  }
28
57
  //# sourceMappingURL=sso-connections.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sso-connections.js","sourceRoot":"","sources":["../../src/client/sso-connections.ts"],"names":[],"mappings":";;AAyFA,wDAsBC;AA/GD,uCAAgD;AAyFhD,SAAgB,sBAAsB,CAAC,OAAkB;IACvD,OAAO;QACL,IAAI;YACF,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,GAAG,CAAC,EAAU;YACZ,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,uBAAuB,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,MAAM,CAAC,IAA6B,EAAE,cAAuB;YAC3D,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QACxF,CAAC;QACD,MAAM,CAAC,EAAU,EAAE,IAA6B;YAC9C,OAAO,OAAO,CAAC,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,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,uBAAuB,IAAA,aAAG,EAAC,EAAE,CAAC,+BAA+B,EAAE,CAAC,CAAC;QAC5G,CAAC;QACD,uFAAuF;QACvF,uBAAuB,CAAC,EAAU;YAChC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,uBAAuB,IAAA,aAAG,EAAC,EAAE,CAAC,sBAAsB,EAAE,CAAC,CAAC;QACnG,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { AtlasOidcError, OIDC_FLOW_COOKIE, OIDC_FLOW_MAX_AGE_SECONDS, oidc, oidc
9
9
  export type { AtlasOidc, AtlasOidcErrorCode, OidcCallbackOptions, OidcClientAuth, OidcIdentity, OidcLogoutUrlOptions, OidcStartOptions, OidcStartResult, VerifyIdTokenOptions, } from './oidc';
10
10
  export * from './webhooks';
11
11
  export * from './referrals';
12
+ export * from './botid';
12
13
  export { createAtlasClient } from './client';
13
14
  export type { AtlasClient } from './client';
14
15
  export * from './client';
@@ -20,5 +21,5 @@ export { verifyPCActn } from './pca/verify';
20
21
  export type { PcaVerdict, PcaContext, VerifyPCActnOptions } from './pca/verify';
21
22
  export { requirePCA, defaultExtract, memoryPcaStore } from './pca/require-pca';
22
23
  export type { RequirePcaOptions, PcaGuardResult, PcaRequestLike, PcaStateStore } from './pca/require-pca';
23
- export { ACCESS_TOKEN_CLOCK_SKEW_SECONDS, DPOP_PROOF_MAX_AGE_SECONDS, buildWwwAuthenticate, createAccessTokenVerifier, memoryDpopReplayStore, protectedResourceMetadata, protectedResourceMetadataPath, verifyAccessToken, } from './oauth-resource';
24
- export type { AccessTokenClaims, AccessTokenErrorCode, AccessTokenResult, AccessTokenVerifierOptions, DpopReplayStore, ResourceRequestLike, } from './oauth-resource';
24
+ export { ACCESS_TOKEN_CLOCK_SKEW_SECONDS, DPOP_PROOF_MAX_AGE_SECONDS, buildWwwAuthenticate, createAccessTokenVerifier, createIntrospector, hmacDpopNonceSource, memoryDpopNonceSource, memoryDpopReplayStore, protectedResourceMetadata, protectedResourceMetadataPath, verifyAccessToken, } from './oauth-resource';
25
+ export type { AccessTokenClaims, AccessTokenErrorCode, AccessTokenResult, AccessTokenVerifierOptions, DpopNonceSource, DpopReplayStore, IntrospectionOptions, ResourceRequestLike, } from './oauth-resource';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.verifyAccessToken = exports.protectedResourceMetadataPath = exports.protectedResourceMetadata = exports.memoryDpopReplayStore = exports.createAccessTokenVerifier = exports.buildWwwAuthenticate = exports.DPOP_PROOF_MAX_AGE_SECONDS = exports.ACCESS_TOKEN_CLOCK_SKEW_SECONDS = exports.memoryPcaStore = exports.defaultExtract = exports.requirePCA = exports.verifyPCActn = exports.REFERALLY_API_VERSION = exports.referralEmailHash = exports.referallySignature = exports.signReferralUpdatedEvent = exports.signReferallyCall = exports.signAtlasReferralCall = exports.TEST_TOKEN_TAMPERS = exports.createTestIssuer = exports.createAtlasClient = exports.resetOidcCaches = exports.oidcVerifyIdToken = exports.oidcStart = exports.oidcLogoutUrl = exports.oidcClearCookie = exports.oidcCallback = exports.oidc = exports.OIDC_FLOW_MAX_AGE_SECONDS = exports.OIDC_FLOW_COOKIE = exports.AtlasOidcError = exports.verifyLogoutToken = exports.memoryLogoutReplayStore = exports.LogoutTokenVerifier = exports.LOGOUT_TOKEN_MAX_AGE_SECONDS = exports.LOGOUT_TOKEN_CLOCK_SKEW_SECONDS = exports.BACKCHANNEL_LOGOUT_EVENT = exports.instanceIdFromPublishableKey = exports.discoveryUrlFor = exports.JwksDiscovery = exports.DiscoveryError = void 0;
17
+ exports.verifyAccessToken = exports.protectedResourceMetadataPath = exports.protectedResourceMetadata = exports.memoryDpopReplayStore = exports.memoryDpopNonceSource = exports.hmacDpopNonceSource = exports.createIntrospector = exports.createAccessTokenVerifier = exports.buildWwwAuthenticate = exports.DPOP_PROOF_MAX_AGE_SECONDS = exports.ACCESS_TOKEN_CLOCK_SKEW_SECONDS = exports.memoryPcaStore = exports.defaultExtract = exports.requirePCA = exports.verifyPCActn = exports.REFERALLY_API_VERSION = exports.referralEmailHash = exports.referallySignature = exports.signReferralUpdatedEvent = exports.signReferallyCall = exports.signAtlasReferralCall = exports.TEST_TOKEN_TAMPERS = exports.createTestIssuer = exports.createAtlasClient = exports.resetOidcCaches = exports.oidcVerifyIdToken = exports.oidcStart = exports.oidcLogoutUrl = exports.oidcClearCookie = exports.oidcCallback = exports.oidc = exports.OIDC_FLOW_MAX_AGE_SECONDS = exports.OIDC_FLOW_COOKIE = exports.AtlasOidcError = exports.verifyLogoutToken = exports.memoryLogoutReplayStore = exports.LogoutTokenVerifier = exports.LOGOUT_TOKEN_MAX_AGE_SECONDS = exports.LOGOUT_TOKEN_CLOCK_SKEW_SECONDS = exports.BACKCHANNEL_LOGOUT_EVENT = exports.instanceIdFromPublishableKey = exports.discoveryUrlFor = exports.JwksDiscovery = exports.DiscoveryError = void 0;
18
18
  // §7.3 token verification — the original surface, unchanged.
19
19
  __exportStar(require("./jwks-cache"), exports);
20
20
  // OIDC discovery of the JWKS URL when only `issuer` is configured.
@@ -51,6 +51,8 @@ Object.defineProperty(exports, "resetOidcCaches", { enumerable: true, get: funct
51
51
  __exportStar(require("./webhooks"), exports);
52
52
  // The Atlas referral protocol, for a referral platform receiving Atlas's signed calls.
53
53
  __exportStar(require("./referrals"), exports);
54
+ // Vercel BotID: sign checkBotId() verdicts on your Vercel route for Atlas's captcha gate.
55
+ __exportStar(require("./botid"), exports);
54
56
  // The typed management client for the secret-key Backend API.
55
57
  var client_1 = require("./client");
56
58
  Object.defineProperty(exports, "createAtlasClient", { enumerable: true, get: function () { return client_1.createAtlasClient; } });
@@ -83,6 +85,9 @@ Object.defineProperty(exports, "ACCESS_TOKEN_CLOCK_SKEW_SECONDS", { enumerable:
83
85
  Object.defineProperty(exports, "DPOP_PROOF_MAX_AGE_SECONDS", { enumerable: true, get: function () { return oauth_resource_1.DPOP_PROOF_MAX_AGE_SECONDS; } });
84
86
  Object.defineProperty(exports, "buildWwwAuthenticate", { enumerable: true, get: function () { return oauth_resource_1.buildWwwAuthenticate; } });
85
87
  Object.defineProperty(exports, "createAccessTokenVerifier", { enumerable: true, get: function () { return oauth_resource_1.createAccessTokenVerifier; } });
88
+ Object.defineProperty(exports, "createIntrospector", { enumerable: true, get: function () { return oauth_resource_1.createIntrospector; } });
89
+ Object.defineProperty(exports, "hmacDpopNonceSource", { enumerable: true, get: function () { return oauth_resource_1.hmacDpopNonceSource; } });
90
+ Object.defineProperty(exports, "memoryDpopNonceSource", { enumerable: true, get: function () { return oauth_resource_1.memoryDpopNonceSource; } });
86
91
  Object.defineProperty(exports, "memoryDpopReplayStore", { enumerable: true, get: function () { return oauth_resource_1.memoryDpopReplayStore; } });
87
92
  Object.defineProperty(exports, "protectedResourceMetadata", { enumerable: true, get: function () { return oauth_resource_1.protectedResourceMetadata; } });
88
93
  Object.defineProperty(exports, "protectedResourceMetadataPath", { enumerable: true, get: function () { return oauth_resource_1.protectedResourceMetadataPath; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6DAA6D;AAC7D,+CAA6B;AAC7B,mEAAmE;AACnE,yCAA2G;AAAlG,2GAAA,cAAc,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,yHAAA,4BAA4B,OAAA;AACrF,2CAAyB;AACzB,mDAAiC;AACjC,8CAA4B;AAE5B,6EAA6E;AAC7E,+CAOwB;AANtB,wHAAA,wBAAwB,OA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HAAA,wBAAwB,OAAA;AACxB,yHAAA,kBAAkB,OAAA;AAClB,wHAAA,iBAAiB,OAAA;AACjB,4HAAA,qBAAqB,OAAA;AAWvB,wFAAwF;AACxF,2CAA2C;AAC3C,uCAA4C;AAAnC,sGAAA,YAAY,OAAA;AAErB,iDAA+E;AAAtE,yGAAA,UAAU,OAAA;AAAE,6GAAA,cAAc,OAAA;AAAE,6GAAA,cAAc,OAAA;AAGnD,8EAA8E;AAC9E,gFAAgF;AAChF,mDAY0B;AAXxB,iIAAA,+BAA+B,OAAA;AAC/B,4HAAA,0BAA0B,OAAA;AAC1B,sHAAA,oBAAoB,OAAA;AACpB,2HAAA,yBAAyB,OAAA;AACzB,oHAAA,kBAAkB,OAAA;AAClB,qHAAA,mBAAmB,OAAA;AACnB,uHAAA,qBAAqB,OAAA;AACrB,uHAAA,qBAAqB,OAAA;AACrB,2HAAA,yBAAyB,OAAA;AACzB,+HAAA,6BAA6B,OAAA;AAC7B,mHAAA,iBAAiB,OAAA"}
@@ -16,6 +16,10 @@ import { type Jwks } from './jwks-cache';
16
16
  * which is exactly what an MCP client needs to discover how to sign in;
17
17
  * - builds the RFC 9728 protected-resource metadata document to serve at
18
18
  * `/.well-known/oauth-protected-resource` on your API's host.
19
+ * - accepts OPAQUE access tokens too (an API, client or instance set to the
20
+ * `opaque` format): with `introspection` configured, a token that is not a
21
+ * JWT is validated at Atlas's introspection endpoint (RFC 7662) with your
22
+ * API's own client credentials, and the answer is cached briefly;
19
23
  * Framework-agnostic: hand it any request with `method`, `url` and `headers`.
20
24
  */
21
25
  /** Clock skew tolerated on `exp`/`nbf` and on DPoP proof `iat`. */
@@ -52,6 +56,37 @@ export interface DpopReplayStore {
52
56
  /** Record `jti` until `expiresAt` (ms); return false when it was already seen. */
53
57
  claim(jti: string, expiresAt: number): Promise<boolean> | boolean;
54
58
  }
59
+ /**
60
+ * Server-provided DPoP nonces (RFC 9449 §8). `current()` is the nonce the API
61
+ * hands out in the `DPoP-Nonce` response header; `valid()` accepts the nonces
62
+ * still in force. A verifier given a source requires every DPoP proof to carry
63
+ * one, answering `use_dpop_nonce` (with a fresh nonce) otherwise.
64
+ */
65
+ export interface DpopNonceSource {
66
+ current(): string | Promise<string>;
67
+ valid(nonce: string): boolean | Promise<boolean>;
68
+ }
69
+ /**
70
+ * An in-process nonce source: a random nonce per window; the current and the
71
+ * previous window's nonce are accepted. Use it when one process serves the API
72
+ * (or with sticky routing); behind several processes, use
73
+ * {@link hmacDpopNonceSource} with a shared secret.
74
+ */
75
+ export declare function memoryDpopNonceSource(options?: {
76
+ windowSeconds?: number;
77
+ now?: () => number;
78
+ }): DpopNonceSource;
79
+ /**
80
+ * A stateless nonce source shared by every process holding the same secret (at
81
+ * least 32 bytes): the nonce for a window is base64url(HMAC-SHA256(secret,
82
+ * "atlas-dpop-nonce:" ‖ uint64-BE(window number))). A nonce is good in the window
83
+ * it was issued in and the next one. The derivation is the same in every Atlas
84
+ * server SDK, so services in different languages sharing the secret agree.
85
+ */
86
+ export declare function hmacDpopNonceSource(secret: string | Uint8Array, options?: {
87
+ windowSeconds?: number;
88
+ now?: () => number;
89
+ }): DpopNonceSource;
55
90
  export declare function memoryDpopReplayStore(max?: number): DpopReplayStore;
56
91
  export interface AccessTokenVerifierOptions {
57
92
  /** Your Atlas instance's issuer (frontend API origin), e.g. https://clerk.example.com. */
@@ -79,12 +114,53 @@ export interface AccessTokenVerifierOptions {
79
114
  /** The public origin of this API, for DPoP `htu` when `request.url` is a path. */
80
115
  publicOrigin?: string;
81
116
  dpopReplayStore?: DpopReplayStore;
117
+ /**
118
+ * Require a server-provided nonce in every DPoP proof (RFC 9449 §8). A proof
119
+ * without a valid one is refused with `use_dpop_nonce`; every result carries
120
+ * `dpopNonce`, to send as the `DPoP-Nonce` response header (the framework
121
+ * adapters do). See {@link memoryDpopNonceSource} / {@link hmacDpopNonceSource}.
122
+ */
123
+ dpopNonces?: DpopNonceSource;
82
124
  /** `WWW-Authenticate` realm. */
83
125
  realm?: string;
126
+ /**
127
+ * Validate opaque access tokens (and, with `introspectJwts`, JWTs too) at
128
+ * Atlas's introspection endpoint. The client must be a confidential client
129
+ * your API lists in its `introspection_client_ids` (or the client the tokens
130
+ * are issued to).
131
+ */
132
+ introspection?: IntrospectionOptions;
84
133
  fetchImpl?: typeof fetch;
85
134
  now?: () => number;
86
135
  }
87
- export type AccessTokenErrorCode = 'invalid_request' | 'invalid_token' | 'insufficient_scope' | 'invalid_dpop_proof';
136
+ export interface IntrospectionOptions {
137
+ clientId: string;
138
+ clientSecret: string;
139
+ /** Default `${issuer}/oauth2/introspect`. */
140
+ endpoint?: string;
141
+ /** How long an active answer is reused, in seconds (default 60; never past the token's `exp`). */
142
+ cacheTtlSeconds?: number;
143
+ /** How long an inactive answer is reused, in seconds (default 10; 0 disables). */
144
+ negativeCacheTtlSeconds?: number;
145
+ /** Most answers kept (default 10 000). */
146
+ cacheMax?: number;
147
+ /**
148
+ * Also introspect JWT access tokens, so a revoked grant or a banned user is
149
+ * refused before the token expires (one cached call per token). Default false:
150
+ * JWTs are verified locally.
151
+ */
152
+ introspectJwts?: boolean;
153
+ }
154
+ /**
155
+ * RFC 7662 introspection with a small TTL cache keyed by the token's SHA-256
156
+ * (the token itself is never kept). Returns the claims of an active token, or
157
+ * null for an inactive one; throws when Atlas could not be reached.
158
+ */
159
+ export declare function createIntrospector(issuer: string, options: IntrospectionOptions, deps?: {
160
+ fetchImpl?: typeof fetch;
161
+ now?: () => number;
162
+ }): (token: string) => Promise<AccessTokenClaims | null>;
163
+ export type AccessTokenErrorCode = 'invalid_request' | 'invalid_token' | 'insufficient_scope' | 'invalid_dpop_proof' | 'use_dpop_nonce';
88
164
  export type AccessTokenResult = {
89
165
  ok: true;
90
166
  claims: AccessTokenClaims;
@@ -92,6 +168,8 @@ export type AccessTokenResult = {
92
168
  subject: string;
93
169
  clientId: string | null;
94
170
  dpopBound: boolean;
171
+ /** With `dpopNonces`: send as the `DPoP-Nonce` response header. */
172
+ dpopNonce?: string;
95
173
  } | {
96
174
  ok: false;
97
175
  status: 400 | 401 | 403;
@@ -99,6 +177,8 @@ export type AccessTokenResult = {
99
177
  description: string;
100
178
  /** Set this response header verbatim. */
101
179
  wwwAuthenticate: string;
180
+ /** With `dpopNonces`: send as the `DPoP-Nonce` response header (always, on `use_dpop_nonce`). */
181
+ dpopNonce?: string;
102
182
  };
103
183
  /**
104
184
  * Build an RFC 6750 / RFC 9449 / RFC 9728 `WWW-Authenticate` challenge.