@oxy.so/core 7.10.6 → 7.11.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.
|
@@ -530,6 +530,29 @@ class OxyServer extends OxyServices_1.OxyServices {
|
|
|
530
530
|
throw new Error('Product grant response attribution differs');
|
|
531
531
|
return snapshot;
|
|
532
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Register accounts this deployment provisioned as its own users, so they count
|
|
535
|
+
* toward {@link applicationAccountTotal}. Workload identity only (the
|
|
536
|
+
* application is the workload's); idempotent; at most
|
|
537
|
+
* `APPLICATION_ACCOUNT_REGISTRATION_BATCH_MAX` ids per call. Ids that are
|
|
538
|
+
* unknown, federated, not personal or archived are skipped and not reported.
|
|
539
|
+
* Returns how many became newly registered.
|
|
540
|
+
*/
|
|
541
|
+
async registerApplicationAccounts(accountIds) {
|
|
542
|
+
const body = contracts_1.applicationAccountRegistrationRequestSchema.parse({ accountIds });
|
|
543
|
+
const answer = await this.serviceRequest('POST', '/application-accounts/self/registrations', body, { cache: false });
|
|
544
|
+
return contracts_1.applicationAccountRegistrationResponseSchema.parse(answer).registered;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* This deployment's eligible registered-account total (local, personal, active,
|
|
548
|
+
* not being closed), from a bounded server snapshot: read `computedAt`,
|
|
549
|
+
* `stale` and `exact` before presenting it. Rejects when no total is available
|
|
550
|
+
* (503 before the first snapshot) — never resolve an unknown total to `0`.
|
|
551
|
+
*/
|
|
552
|
+
async applicationAccountTotal() {
|
|
553
|
+
const answer = await this.serviceRequest('GET', '/application-accounts/self/total', undefined, { cache: false });
|
|
554
|
+
return contracts_1.applicationAccountTotalSchema.parse(answer);
|
|
555
|
+
}
|
|
533
556
|
async serviceRequest(method, url, data, options = {}) {
|
|
534
557
|
const target = new URL(/^https?:\/\//i.test(url)
|
|
535
558
|
? url
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OxyRequesterClient } from './requesterClient.js';
|
|
2
|
-
import { serviceIntrospectionSchema, resourceIntrospectionSchema, serviceTokenOptionsSchema, subjectProductAccessQuerySchema, subjectProductGrantSnapshotSchema, } from '@oxy.so/contracts';
|
|
2
|
+
import { applicationAccountRegistrationRequestSchema, applicationAccountRegistrationResponseSchema, applicationAccountTotalSchema, serviceIntrospectionSchema, resourceIntrospectionSchema, serviceTokenOptionsSchema, subjectProductAccessQuerySchema, subjectProductGrantSnapshotSchema, } from '@oxy.so/contracts';
|
|
3
3
|
/**
|
|
4
4
|
* `OxyServer` — the Oxy client for a backend.
|
|
5
5
|
*
|
|
@@ -526,6 +526,29 @@ export class OxyServer extends OxyServices {
|
|
|
526
526
|
throw new Error('Product grant response attribution differs');
|
|
527
527
|
return snapshot;
|
|
528
528
|
}
|
|
529
|
+
/**
|
|
530
|
+
* Register accounts this deployment provisioned as its own users, so they count
|
|
531
|
+
* toward {@link applicationAccountTotal}. Workload identity only (the
|
|
532
|
+
* application is the workload's); idempotent; at most
|
|
533
|
+
* `APPLICATION_ACCOUNT_REGISTRATION_BATCH_MAX` ids per call. Ids that are
|
|
534
|
+
* unknown, federated, not personal or archived are skipped and not reported.
|
|
535
|
+
* Returns how many became newly registered.
|
|
536
|
+
*/
|
|
537
|
+
async registerApplicationAccounts(accountIds) {
|
|
538
|
+
const body = applicationAccountRegistrationRequestSchema.parse({ accountIds });
|
|
539
|
+
const answer = await this.serviceRequest('POST', '/application-accounts/self/registrations', body, { cache: false });
|
|
540
|
+
return applicationAccountRegistrationResponseSchema.parse(answer).registered;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* This deployment's eligible registered-account total (local, personal, active,
|
|
544
|
+
* not being closed), from a bounded server snapshot: read `computedAt`,
|
|
545
|
+
* `stale` and `exact` before presenting it. Rejects when no total is available
|
|
546
|
+
* (503 before the first snapshot) — never resolve an unknown total to `0`.
|
|
547
|
+
*/
|
|
548
|
+
async applicationAccountTotal() {
|
|
549
|
+
const answer = await this.serviceRequest('GET', '/application-accounts/self/total', undefined, { cache: false });
|
|
550
|
+
return applicationAccountTotalSchema.parse(answer);
|
|
551
|
+
}
|
|
529
552
|
async serviceRequest(method, url, data, options = {}) {
|
|
530
553
|
const target = new URL(/^https?:\/\//i.test(url)
|
|
531
554
|
? url
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OxyRequesterClient } from './requesterClient';
|
|
2
2
|
import type { RequesterProof } from './requesterContext';
|
|
3
|
-
import { type ResourceIntrospection, type ServiceIntrospection, type ServiceTokenOptions, type SubjectProductAccessQuery, type SubjectProductGrantSnapshot } from '@oxy.so/contracts';
|
|
3
|
+
import { type ApplicationAccountTotal, type ResourceIntrospection, type ServiceIntrospection, type ServiceTokenOptions, type SubjectProductAccessQuery, type SubjectProductGrantSnapshot } from '@oxy.so/contracts';
|
|
4
4
|
import { OxyServices, type OxyConfig } from '../OxyServices';
|
|
5
5
|
import type { HttpMethod } from '../client/context';
|
|
6
6
|
import type { RequestOptions, ResponsePayload } from '../HttpService';
|
|
@@ -267,6 +267,22 @@ export declare class OxyServer extends OxyServices {
|
|
|
267
267
|
productGrantSnapshotForUser(query: SubjectProductAccessQuery, accessToken: string): Promise<SubjectProductGrantSnapshot>;
|
|
268
268
|
/** Offline metering read: the API requires this app's live consent for this exact subject. */
|
|
269
269
|
productGrantSnapshotForService(query: SubjectProductAccessQuery): Promise<SubjectProductGrantSnapshot>;
|
|
270
|
+
/**
|
|
271
|
+
* Register accounts this deployment provisioned as its own users, so they count
|
|
272
|
+
* toward {@link applicationAccountTotal}. Workload identity only (the
|
|
273
|
+
* application is the workload's); idempotent; at most
|
|
274
|
+
* `APPLICATION_ACCOUNT_REGISTRATION_BATCH_MAX` ids per call. Ids that are
|
|
275
|
+
* unknown, federated, not personal or archived are skipped and not reported.
|
|
276
|
+
* Returns how many became newly registered.
|
|
277
|
+
*/
|
|
278
|
+
registerApplicationAccounts(accountIds: readonly string[]): Promise<number>;
|
|
279
|
+
/**
|
|
280
|
+
* This deployment's eligible registered-account total (local, personal, active,
|
|
281
|
+
* not being closed), from a bounded server snapshot: read `computedAt`,
|
|
282
|
+
* `stale` and `exact` before presenting it. Rejects when no total is available
|
|
283
|
+
* (503 before the first snapshot) — never resolve an unknown total to `0`.
|
|
284
|
+
*/
|
|
285
|
+
applicationAccountTotal(): Promise<ApplicationAccountTotal>;
|
|
270
286
|
serviceRequest<T>(method: HttpMethod, url: string, data?: unknown, options?: RequestOptions & {
|
|
271
287
|
actAs?: string;
|
|
272
288
|
requesterToken?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.11.0",
|
|
4
4
|
"description": "OxyHQ SDK Foundation — API client, authentication, cryptographic identity, and shared utilities",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
"dependencies": {
|
|
182
182
|
"@noble/ciphers": "^1.3.0",
|
|
183
183
|
"@noble/hashes": "^1.8.0",
|
|
184
|
-
"@oxy.so/contracts": "6.
|
|
184
|
+
"@oxy.so/contracts": "6.3.0",
|
|
185
185
|
"@oxy.so/protocol": "^1.5.1",
|
|
186
186
|
"@oxy.so/telemetry": "^2.1.0",
|
|
187
187
|
"@scure/bip39": "^1.6.0",
|
package/src/server/OxyServer.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { OxyRequesterClient } from './requesterClient';
|
|
2
2
|
import type { RequesterProof } from './requesterContext';
|
|
3
3
|
import {
|
|
4
|
+
applicationAccountRegistrationRequestSchema,
|
|
5
|
+
applicationAccountRegistrationResponseSchema,
|
|
6
|
+
applicationAccountTotalSchema,
|
|
7
|
+
type ApplicationAccountTotal,
|
|
4
8
|
type OxySessionRevocationEvent,
|
|
5
9
|
serviceIntrospectionSchema,
|
|
6
10
|
resourceIntrospectionSchema,
|
|
@@ -786,6 +790,41 @@ export class OxyServer extends OxyServices {
|
|
|
786
790
|
return snapshot;
|
|
787
791
|
}
|
|
788
792
|
|
|
793
|
+
/**
|
|
794
|
+
* Register accounts this deployment provisioned as its own users, so they count
|
|
795
|
+
* toward {@link applicationAccountTotal}. Workload identity only (the
|
|
796
|
+
* application is the workload's); idempotent; at most
|
|
797
|
+
* `APPLICATION_ACCOUNT_REGISTRATION_BATCH_MAX` ids per call. Ids that are
|
|
798
|
+
* unknown, federated, not personal or archived are skipped and not reported.
|
|
799
|
+
* Returns how many became newly registered.
|
|
800
|
+
*/
|
|
801
|
+
async registerApplicationAccounts(accountIds: readonly string[]): Promise<number> {
|
|
802
|
+
const body = applicationAccountRegistrationRequestSchema.parse({ accountIds });
|
|
803
|
+
const answer = await this.serviceRequest<unknown>(
|
|
804
|
+
'POST',
|
|
805
|
+
'/application-accounts/self/registrations',
|
|
806
|
+
body,
|
|
807
|
+
{ cache: false },
|
|
808
|
+
);
|
|
809
|
+
return applicationAccountRegistrationResponseSchema.parse(answer).registered;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* This deployment's eligible registered-account total (local, personal, active,
|
|
814
|
+
* not being closed), from a bounded server snapshot: read `computedAt`,
|
|
815
|
+
* `stale` and `exact` before presenting it. Rejects when no total is available
|
|
816
|
+
* (503 before the first snapshot) — never resolve an unknown total to `0`.
|
|
817
|
+
*/
|
|
818
|
+
async applicationAccountTotal(): Promise<ApplicationAccountTotal> {
|
|
819
|
+
const answer = await this.serviceRequest<unknown>(
|
|
820
|
+
'GET',
|
|
821
|
+
'/application-accounts/self/total',
|
|
822
|
+
undefined,
|
|
823
|
+
{ cache: false },
|
|
824
|
+
);
|
|
825
|
+
return applicationAccountTotalSchema.parse(answer);
|
|
826
|
+
}
|
|
827
|
+
|
|
789
828
|
async serviceRequest<T>(
|
|
790
829
|
method: HttpMethod,
|
|
791
830
|
url: string,
|