@witnium-tech/witniumchain 0.5.0 → 0.6.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/FRONTEND-INTEGRATION.md +265 -0
- package/dist/index.d.mts +215 -9
- package/dist/index.d.ts +215 -9
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -5
package/dist/index.d.ts
CHANGED
|
@@ -915,6 +915,139 @@ interface paths$1 {
|
|
|
915
915
|
patch?: never;
|
|
916
916
|
trace?: never;
|
|
917
917
|
};
|
|
918
|
+
"/v1/orgs": {
|
|
919
|
+
parameters: {
|
|
920
|
+
query?: never;
|
|
921
|
+
header?: never;
|
|
922
|
+
path?: never;
|
|
923
|
+
cookie?: never;
|
|
924
|
+
};
|
|
925
|
+
get?: never;
|
|
926
|
+
put?: never;
|
|
927
|
+
/**
|
|
928
|
+
* Create an organisation with client-generated keys
|
|
929
|
+
* @description Phase RBAC Thread D — explicit org creation. The caller generates the owner key and the initial signing key client-side; Witnium never holds the private bytes. The response includes the freshly-deployed contract address and a one-time email-verify token.
|
|
930
|
+
*/
|
|
931
|
+
post: {
|
|
932
|
+
parameters: {
|
|
933
|
+
query?: never;
|
|
934
|
+
header?: never;
|
|
935
|
+
path?: never;
|
|
936
|
+
cookie?: never;
|
|
937
|
+
};
|
|
938
|
+
requestBody?: {
|
|
939
|
+
content: {
|
|
940
|
+
"application/json": {
|
|
941
|
+
/** @description Display name of the organisation. */
|
|
942
|
+
orgName: string;
|
|
943
|
+
/**
|
|
944
|
+
* Format: email
|
|
945
|
+
* @description Email of the founding org-admin. Receives the email-verify link.
|
|
946
|
+
* @example user@example.com
|
|
947
|
+
*/
|
|
948
|
+
adminEmail: string;
|
|
949
|
+
/** @description Password for the founding org-admin. argon2id-hashed server-side. Minimum 12 chars; callers are expected to gate via a strength meter. */
|
|
950
|
+
adminPassword: string;
|
|
951
|
+
/**
|
|
952
|
+
* @description Client-generated Ed25519 public key that controls signing-key add/revoke on the new contract. Witnium never sees the private bytes (non-custodial).
|
|
953
|
+
* @example 4cdde7a3e3a1d8a48d2b9eaf2bcbe2db1d57d3e1a8d6c20e0a86c0f9c4b6cf2e
|
|
954
|
+
*/
|
|
955
|
+
ownerPublicKey: string;
|
|
956
|
+
/**
|
|
957
|
+
* @description First signing key registered on the contract. Often the same identity as the org-admin's browser-held key (Mode 1) but may also be the public half of a separately-registered Vault-Transit delegated key (Mode 3).
|
|
958
|
+
* @example 4cdde7a3e3a1d8a48d2b9eaf2bcbe2db1d57d3e1a8d6c20e0a86c0f9c4b6cf2e
|
|
959
|
+
*/
|
|
960
|
+
initialSigningPublicKey: string;
|
|
961
|
+
/** @description Captcha proof. Not yet wired (no captcha provider configured); reserved for when one is added. Public endpoint without it relies on downstream billing/credit-ledger gates against abuse. */
|
|
962
|
+
captchaToken?: string;
|
|
963
|
+
};
|
|
964
|
+
};
|
|
965
|
+
};
|
|
966
|
+
responses: {
|
|
967
|
+
/** @description Success */
|
|
968
|
+
200: {
|
|
969
|
+
headers: {
|
|
970
|
+
[name: string]: unknown;
|
|
971
|
+
};
|
|
972
|
+
content: {
|
|
973
|
+
"application/json": {
|
|
974
|
+
/**
|
|
975
|
+
* @description UUID v4
|
|
976
|
+
* @example 550e8400-e29b-41d4-a716-446655440000
|
|
977
|
+
*/
|
|
978
|
+
orgId: string;
|
|
979
|
+
/**
|
|
980
|
+
* @description UUID v4
|
|
981
|
+
* @example 550e8400-e29b-41d4-a716-446655440000
|
|
982
|
+
*/
|
|
983
|
+
userId: string;
|
|
984
|
+
/** @description Address of the freshly-deployed contract. */
|
|
985
|
+
contractAddress: string;
|
|
986
|
+
/** @description Semantic on-chain Solidity version (e.g. "5.0.0"). */
|
|
987
|
+
contractVersion: string;
|
|
988
|
+
/** @description Email-verify token. Already sent to adminEmail; echoed here for flows that prefer to surface a "click this link" in their own UI. */
|
|
989
|
+
emailVerifyToken: string;
|
|
990
|
+
};
|
|
991
|
+
};
|
|
992
|
+
};
|
|
993
|
+
/** @description Bad Request — validation failed */
|
|
994
|
+
400: {
|
|
995
|
+
headers: {
|
|
996
|
+
[name: string]: unknown;
|
|
997
|
+
};
|
|
998
|
+
content: {
|
|
999
|
+
"application/json": {
|
|
1000
|
+
/**
|
|
1001
|
+
* @description HTTP status code
|
|
1002
|
+
* @example 400
|
|
1003
|
+
*/
|
|
1004
|
+
statusCode?: number;
|
|
1005
|
+
/**
|
|
1006
|
+
* @description Short error label
|
|
1007
|
+
* @example Bad Request
|
|
1008
|
+
*/
|
|
1009
|
+
error?: string;
|
|
1010
|
+
/**
|
|
1011
|
+
* @description Human-readable error message. Validation errors from `ZodError.flatten()` may be returned as an array.
|
|
1012
|
+
* @example Validation failed
|
|
1013
|
+
*/
|
|
1014
|
+
message: string | string[];
|
|
1015
|
+
};
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
/** @description Conflict */
|
|
1019
|
+
409: {
|
|
1020
|
+
headers: {
|
|
1021
|
+
[name: string]: unknown;
|
|
1022
|
+
};
|
|
1023
|
+
content: {
|
|
1024
|
+
"application/json": {
|
|
1025
|
+
/**
|
|
1026
|
+
* @description HTTP status code
|
|
1027
|
+
* @example 400
|
|
1028
|
+
*/
|
|
1029
|
+
statusCode?: number;
|
|
1030
|
+
/**
|
|
1031
|
+
* @description Short error label
|
|
1032
|
+
* @example Bad Request
|
|
1033
|
+
*/
|
|
1034
|
+
error?: string;
|
|
1035
|
+
/**
|
|
1036
|
+
* @description Human-readable error message. Validation errors from `ZodError.flatten()` may be returned as an array.
|
|
1037
|
+
* @example Validation failed
|
|
1038
|
+
*/
|
|
1039
|
+
message: string | string[];
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
};
|
|
1043
|
+
};
|
|
1044
|
+
};
|
|
1045
|
+
delete?: never;
|
|
1046
|
+
options?: never;
|
|
1047
|
+
head?: never;
|
|
1048
|
+
patch?: never;
|
|
1049
|
+
trace?: never;
|
|
1050
|
+
};
|
|
918
1051
|
"/v1/orgs/me": {
|
|
919
1052
|
parameters: {
|
|
920
1053
|
query?: never;
|
|
@@ -9142,6 +9275,8 @@ type PublicOrgResponse = Res<'/v1/orgs/me', 'get'>;
|
|
|
9142
9275
|
type CreateUserRequest = Req<'/v1/orgs/me/users', 'post'>;
|
|
9143
9276
|
type CreateUserResponse = Res<'/v1/orgs/me/users', 'post'>;
|
|
9144
9277
|
type ListUsersResponse = Res<'/v1/orgs/me/users', 'get'>;
|
|
9278
|
+
type CreateOrgRequest = Req<'/v1/orgs', 'post'>;
|
|
9279
|
+
type CreateOrgResponse = Res<'/v1/orgs', 'post'>;
|
|
9145
9280
|
type CreateOrganizationRequest = Req<'/v1/admin/organizations', 'post'>;
|
|
9146
9281
|
type CreateOrganizationResponse = Res<'/v1/admin/organizations', 'post'>;
|
|
9147
9282
|
type SetAccountTypeRequest = Req<'/v1/admin/organizations/{id}/account-type', 'patch'>;
|
|
@@ -9160,11 +9295,11 @@ type SignRequest = Req<'/v1/sign', 'post'>;
|
|
|
9160
9295
|
type SignResponse = Res<'/v1/sign', 'post'>;
|
|
9161
9296
|
type ProvisionContractRequest = Req<'/v1/contracts/provision', 'post'>;
|
|
9162
9297
|
type ProvisionContractResponse = Res<'/v1/contracts/provision', 'post'>;
|
|
9163
|
-
type AddSigningKeyRequest = Req<'/v1/keys', 'post'>;
|
|
9298
|
+
type AddSigningKeyRequest$1 = Req<'/v1/keys', 'post'>;
|
|
9164
9299
|
type AddSigningKeyResponse = Res<'/v1/keys', 'post'>;
|
|
9165
|
-
type RevokeSigningKeyRequest = Req<'/v1/keys/revoke', 'post'>;
|
|
9300
|
+
type RevokeSigningKeyRequest$1 = Req<'/v1/keys/revoke', 'post'>;
|
|
9166
9301
|
type RevokeSigningKeyResponse = Res<'/v1/keys/revoke', 'post'>;
|
|
9167
|
-
type PauseRequest = Req<'/v1/contracts/pause', 'post'>;
|
|
9302
|
+
type PauseRequest$1 = Req<'/v1/contracts/pause', 'post'>;
|
|
9168
9303
|
type PauseResponse = Res<'/v1/contracts/pause', 'post'>;
|
|
9169
9304
|
type UnpauseRequest = Req<'/v1/contracts/unpause', 'post'>;
|
|
9170
9305
|
type UnpauseResponse = Res<'/v1/contracts/unpause', 'post'>;
|
|
@@ -9441,6 +9576,17 @@ declare class WitniumchainClient {
|
|
|
9441
9576
|
*/
|
|
9442
9577
|
me(): Promise<AccountResponse>;
|
|
9443
9578
|
signup(body: SignupRequest): Promise<SignupResponse>;
|
|
9579
|
+
/**
|
|
9580
|
+
* Self-serve org creation (Phase RBAC Thread D). One public call that
|
|
9581
|
+
* creates the admin user, the org, the org-admin membership, and deploys
|
|
9582
|
+
* the contract with the caller's client-generated `ownerPublicKey` +
|
|
9583
|
+
* `initialSigningPublicKey`. Witnium never sees the private bytes.
|
|
9584
|
+
*
|
|
9585
|
+
* Returns `{ orgId, userId, contractAddress, contractVersion,
|
|
9586
|
+
* emailVerifyToken }`. The verify token is also emailed; it's echoed here
|
|
9587
|
+
* for UIs that prefer to render the verify link themselves.
|
|
9588
|
+
*/
|
|
9589
|
+
createOrg(body: CreateOrgRequest): Promise<CreateOrgResponse>;
|
|
9444
9590
|
verifyEmail(token: string): Promise<VerifyEmailResponse>;
|
|
9445
9591
|
login(body: LoginRequest): Promise<LoginResponse>;
|
|
9446
9592
|
logout(): Promise<LogoutResponse>;
|
|
@@ -9465,9 +9611,9 @@ declare class WitniumchainClient {
|
|
|
9465
9611
|
revokeDelegatedKey(id: string): Promise<RevokeDelegatedKeyResponse>;
|
|
9466
9612
|
sign(body: SignRequest, requestId?: string): Promise<SignResponse>;
|
|
9467
9613
|
provisionContract(body: ProvisionContractRequest): Promise<ProvisionContractResponse>;
|
|
9468
|
-
addSigningKey(body: AddSigningKeyRequest): Promise<AddSigningKeyResponse>;
|
|
9469
|
-
revokeSigningKey(body: RevokeSigningKeyRequest): Promise<RevokeSigningKeyResponse>;
|
|
9470
|
-
pauseContract(body: PauseRequest): Promise<PauseResponse>;
|
|
9614
|
+
addSigningKey(body: AddSigningKeyRequest$1): Promise<AddSigningKeyResponse>;
|
|
9615
|
+
revokeSigningKey(body: RevokeSigningKeyRequest$1): Promise<RevokeSigningKeyResponse>;
|
|
9616
|
+
pauseContract(body: PauseRequest$1): Promise<PauseResponse>;
|
|
9471
9617
|
unpauseContract(body: UnpauseRequest): Promise<UnpauseResponse>;
|
|
9472
9618
|
proposeWitness(contractAddress: string, body: ProposeWitnessRequest, idempotencyKey?: string): Promise<ProposeWitnessResponse>;
|
|
9473
9619
|
signWitness(contractAddress: string, witnessId: string, body: SignWitnessRequest): Promise<SignWitnessResponse>;
|
|
@@ -9690,8 +9836,8 @@ declare class SigningKeys {
|
|
|
9690
9836
|
* WitniumchainClient.getAccount} and returns the `signingKeys` slice.
|
|
9691
9837
|
*/
|
|
9692
9838
|
list(): Promise<AccountResponse['signingKeys']>;
|
|
9693
|
-
add(body: AddSigningKeyRequest): Promise<AddSigningKeyResponse>;
|
|
9694
|
-
revoke(body: RevokeSigningKeyRequest): Promise<RevokeSigningKeyResponse>;
|
|
9839
|
+
add(body: AddSigningKeyRequest$1): Promise<AddSigningKeyResponse>;
|
|
9840
|
+
revoke(body: RevokeSigningKeyRequest$1): Promise<RevokeSigningKeyResponse>;
|
|
9695
9841
|
}
|
|
9696
9842
|
/** `client.oauth.sessions.*` — list and revoke active OAuth sessions. */
|
|
9697
9843
|
declare class OauthNamespace {
|
|
@@ -9792,6 +9938,66 @@ declare class WitniumchainAdminClient {
|
|
|
9792
9938
|
adjustCredits(orgId: string, delta: number, note?: string): Promise<AdjustCreditsResponse>;
|
|
9793
9939
|
}
|
|
9794
9940
|
|
|
9941
|
+
type Body<T> = T extends {
|
|
9942
|
+
content: {
|
|
9943
|
+
'application/json': infer J;
|
|
9944
|
+
};
|
|
9945
|
+
} ? J : never;
|
|
9946
|
+
type Resp<T> = T extends {
|
|
9947
|
+
content: {
|
|
9948
|
+
'application/json': infer J;
|
|
9949
|
+
};
|
|
9950
|
+
} ? J : never;
|
|
9951
|
+
type DeployContractRequest = Body<NonNullable<paths['/v5/contracts/deploy']['post']['requestBody']>>;
|
|
9952
|
+
type DeployContractResponse = Resp<paths['/v5/contracts/deploy']['post']['responses']['200']>;
|
|
9953
|
+
type AddSigningKeyRequest = Body<NonNullable<paths['/v5/contracts/{contractAddress}/keys']['post']['requestBody']>>;
|
|
9954
|
+
type OwnerOpResponse = Resp<paths['/v5/contracts/{contractAddress}/keys']['post']['responses']['200']>;
|
|
9955
|
+
type RevokeSigningKeyRequest = {
|
|
9956
|
+
keyToRevoke: string;
|
|
9957
|
+
ownerNonce: number;
|
|
9958
|
+
ownerSignature: string;
|
|
9959
|
+
};
|
|
9960
|
+
type PauseRequest = {
|
|
9961
|
+
ownerNonce: number;
|
|
9962
|
+
ownerSignature: string;
|
|
9963
|
+
};
|
|
9964
|
+
interface WitniumchainChainAdminClientConfig {
|
|
9965
|
+
/** chain-api base URL, e.g. https://api.witniumchain.com. Trailing slash optional. */
|
|
9966
|
+
baseUrl: string;
|
|
9967
|
+
/**
|
|
9968
|
+
* Static bearer token (legacy `BEARER_TOKEN`). Mutually exclusive with
|
|
9969
|
+
* `adminTokenProvider`. Phase RBAC checkpoint 3 retires this in favour of
|
|
9970
|
+
* the provider.
|
|
9971
|
+
*/
|
|
9972
|
+
adminToken?: string;
|
|
9973
|
+
/**
|
|
9974
|
+
* Async function that yields a fresh accounts-minted service-principal JWT
|
|
9975
|
+
* with `aud=https://api.witniumchain.com/admin` + `role=org-admin` on each
|
|
9976
|
+
* call. Implementations typically cache against the token's `exp`. Returned
|
|
9977
|
+
* tokens MUST satisfy chain-api's DashboardJwtGuard.
|
|
9978
|
+
*/
|
|
9979
|
+
adminTokenProvider?: () => Promise<string>;
|
|
9980
|
+
/** Per-request timeout in milliseconds. Default 30000. */
|
|
9981
|
+
timeout?: number;
|
|
9982
|
+
/** Alternate fetch implementation, e.g. for tests. Default globalThis.fetch. */
|
|
9983
|
+
fetch?: typeof fetch;
|
|
9984
|
+
}
|
|
9985
|
+
declare class WitniumchainChainAdminClient {
|
|
9986
|
+
private readonly baseUrl;
|
|
9987
|
+
private readonly adminToken;
|
|
9988
|
+
private readonly adminTokenProvider;
|
|
9989
|
+
private readonly timeout;
|
|
9990
|
+
private readonly fetchImpl;
|
|
9991
|
+
constructor(config: WitniumchainChainAdminClientConfig);
|
|
9992
|
+
deployContract(body: DeployContractRequest): Promise<DeployContractResponse>;
|
|
9993
|
+
addSigningKey(contractAddress: string, body: AddSigningKeyRequest): Promise<OwnerOpResponse>;
|
|
9994
|
+
revokeSigningKey(contractAddress: string, body: RevokeSigningKeyRequest): Promise<OwnerOpResponse>;
|
|
9995
|
+
pauseContract(contractAddress: string, body: PauseRequest): Promise<OwnerOpResponse>;
|
|
9996
|
+
unpauseContract(contractAddress: string, body: PauseRequest): Promise<OwnerOpResponse>;
|
|
9997
|
+
private resolveToken;
|
|
9998
|
+
private req;
|
|
9999
|
+
}
|
|
10000
|
+
|
|
9795
10001
|
/**
|
|
9796
10002
|
* WitniumchainOrgClient — org-admin facade over the accounts API.
|
|
9797
10003
|
*
|
|
@@ -9864,4 +10070,4 @@ declare class WitniumchainApiError extends Error {
|
|
|
9864
10070
|
});
|
|
9865
10071
|
}
|
|
9866
10072
|
|
|
9867
|
-
export { type AccountResponse, type AccountType, type paths$1 as AccountsPaths, type AddSigningKeyRequest, type AddSigningKeyResponse, type AdjustCreditsRequest, type AdjustCreditsResponse, type BeginOAuthLoginArgs, type BeginOAuthLoginResult, type paths as ChainPaths, type CheckoutRequest, type CheckoutResponse, type CreateOrganizationRequest, type CreateOrganizationResponse, type CreateUserRequest, type CreateUserResponse, DelegatedKeys, type FinalizeWitnessResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetWitnessResponse, type HealthLiveResponse, type HealthReadyResponse, type LedgerResponse, type ListDelegatedKeysResponse, type ListOauthSessionsResponse, type ListUsersResponse, type LoginRequest, type LoginResponse, type LogoutResponse, MfaNamespace, MfaRecoveryCodes, MfaTotp, type OAuthTokenSnapshot, OauthNamespace, OauthSessions, OrgUsers, type OwnerSigner, type PauseRequest, type PauseResponse, type PkceVerifierStorage, type PortalResponse, type PrepareDelegatedKeyRequest, type PreparedDelegatedKeyResponse, type ProposeWitnessRequest, type ProposeWitnessResponse, type ProvisionContractRequest, type ProvisionContractResponse, type ProvisionDelegatedKeyArgs, type ProvisionDelegatedKeyResult, type PublicOrgResponse, type RecoveryCodesRegenerateResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDelegatedKeyResponse, type RevokeSigningKeyRequest, type RevokeSigningKeyResponse, type RevokeWitnessRequest, type RevokeWitnessResponse, type RotateApiKeyResponse, type SetAccountTypeRequest, type SetAccountTypeResponse, type SignRequest, type SignResponse, type SignWitnessRequest, type SignWitnessResponse, type SignedRequestSigner, SigningKeys, type SignupRequest, type SignupResponse, type SubmitDelegatedKeyRequest, type SubmitDelegatedKeyResponse, Subscriptions, type TotpConfirmRequest, type TotpConfirmResponse, type TotpDisableResponse, type TotpEnrollResponse, type UnpauseRequest, type UnpauseResponse, type VerifyEmailResponse, type VerifyOrganizationResponse, WitniumchainAdminClient, type WitniumchainAdminClientConfig, WitniumchainApiError, WitniumchainClient, type WitniumchainClientConfig, WitniumchainOrgClient, type WitniumchainOrgClientConfig, defaultVerifierStorage };
|
|
10073
|
+
export { type AccountResponse, type AccountType, type paths$1 as AccountsPaths, type AddSigningKeyRequest$1 as AddSigningKeyRequest, type AddSigningKeyResponse, type AdjustCreditsRequest, type AdjustCreditsResponse, type BeginOAuthLoginArgs, type BeginOAuthLoginResult, type paths as ChainPaths, type CheckoutRequest, type CheckoutResponse, type CreateOrgRequest, type CreateOrgResponse, type CreateOrganizationRequest, type CreateOrganizationResponse, type CreateUserRequest, type CreateUserResponse, DelegatedKeys, type FinalizeWitnessResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetWitnessResponse, type HealthLiveResponse, type HealthReadyResponse, type LedgerResponse, type ListDelegatedKeysResponse, type ListOauthSessionsResponse, type ListUsersResponse, type LoginRequest, type LoginResponse, type LogoutResponse, MfaNamespace, MfaRecoveryCodes, MfaTotp, type OAuthTokenSnapshot, OauthNamespace, OauthSessions, OrgUsers, type OwnerSigner, type PauseRequest$1 as PauseRequest, type PauseResponse, type PkceVerifierStorage, type PortalResponse, type PrepareDelegatedKeyRequest, type PreparedDelegatedKeyResponse, type ProposeWitnessRequest, type ProposeWitnessResponse, type ProvisionContractRequest, type ProvisionContractResponse, type ProvisionDelegatedKeyArgs, type ProvisionDelegatedKeyResult, type PublicOrgResponse, type RecoveryCodesRegenerateResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDelegatedKeyResponse, type RevokeSigningKeyRequest$1 as RevokeSigningKeyRequest, type RevokeSigningKeyResponse, type RevokeWitnessRequest, type RevokeWitnessResponse, type RotateApiKeyResponse, type SetAccountTypeRequest, type SetAccountTypeResponse, type SignRequest, type SignResponse, type SignWitnessRequest, type SignWitnessResponse, type SignedRequestSigner, SigningKeys, type SignupRequest, type SignupResponse, type SubmitDelegatedKeyRequest, type SubmitDelegatedKeyResponse, Subscriptions, type TotpConfirmRequest, type TotpConfirmResponse, type TotpDisableResponse, type TotpEnrollResponse, type UnpauseRequest, type UnpauseResponse, type VerifyEmailResponse, type VerifyOrganizationResponse, WitniumchainAdminClient, type WitniumchainAdminClientConfig, WitniumchainApiError, WitniumchainChainAdminClient, type WitniumchainChainAdminClientConfig, WitniumchainClient, type WitniumchainClientConfig, WitniumchainOrgClient, type WitniumchainOrgClientConfig, defaultVerifierStorage };
|
package/dist/index.js
CHANGED
|
@@ -157,6 +157,19 @@ var WitniumchainClient = class {
|
|
|
157
157
|
signup(body) {
|
|
158
158
|
return this.req("POST", "/v1/auth/signup", { auth: "Public", body });
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Self-serve org creation (Phase RBAC Thread D). One public call that
|
|
162
|
+
* creates the admin user, the org, the org-admin membership, and deploys
|
|
163
|
+
* the contract with the caller's client-generated `ownerPublicKey` +
|
|
164
|
+
* `initialSigningPublicKey`. Witnium never sees the private bytes.
|
|
165
|
+
*
|
|
166
|
+
* Returns `{ orgId, userId, contractAddress, contractVersion,
|
|
167
|
+
* emailVerifyToken }`. The verify token is also emailed; it's echoed here
|
|
168
|
+
* for UIs that prefer to render the verify link themselves.
|
|
169
|
+
*/
|
|
170
|
+
createOrg(body) {
|
|
171
|
+
return this.req("POST", "/v1/orgs", { auth: "Public", body });
|
|
172
|
+
}
|
|
160
173
|
verifyEmail(token) {
|
|
161
174
|
return this.req("GET", "/v1/auth/verify", {
|
|
162
175
|
auth: "Public",
|
|
@@ -1346,6 +1359,106 @@ var WitniumchainAdminClient = class {
|
|
|
1346
1359
|
}
|
|
1347
1360
|
};
|
|
1348
1361
|
|
|
1362
|
+
// src/chain-admin-client.ts
|
|
1363
|
+
var WitniumchainChainAdminClient = class {
|
|
1364
|
+
baseUrl;
|
|
1365
|
+
adminToken;
|
|
1366
|
+
adminTokenProvider;
|
|
1367
|
+
timeout;
|
|
1368
|
+
fetchImpl;
|
|
1369
|
+
constructor(config) {
|
|
1370
|
+
if (!config.baseUrl) {
|
|
1371
|
+
throw new Error("WitniumchainChainAdminClient: baseUrl is required");
|
|
1372
|
+
}
|
|
1373
|
+
if (config.adminToken && config.adminTokenProvider) {
|
|
1374
|
+
throw new Error(
|
|
1375
|
+
"WitniumchainChainAdminClient: pass either adminToken (static) or adminTokenProvider (OAuth), not both"
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
if (!config.adminToken && !config.adminTokenProvider) {
|
|
1379
|
+
throw new Error(
|
|
1380
|
+
"WitniumchainChainAdminClient: one of adminToken or adminTokenProvider is required"
|
|
1381
|
+
);
|
|
1382
|
+
}
|
|
1383
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
1384
|
+
this.adminToken = config.adminToken;
|
|
1385
|
+
this.adminTokenProvider = config.adminTokenProvider;
|
|
1386
|
+
this.timeout = config.timeout ?? 3e4;
|
|
1387
|
+
this.fetchImpl = config.fetch ?? globalThis.fetch;
|
|
1388
|
+
}
|
|
1389
|
+
async deployContract(body) {
|
|
1390
|
+
return this.req("POST", "/v5/contracts/deploy", body);
|
|
1391
|
+
}
|
|
1392
|
+
async addSigningKey(contractAddress, body) {
|
|
1393
|
+
return this.req(
|
|
1394
|
+
"POST",
|
|
1395
|
+
`/v5/contracts/${encodeURIComponent(contractAddress)}/keys`,
|
|
1396
|
+
body
|
|
1397
|
+
);
|
|
1398
|
+
}
|
|
1399
|
+
async revokeSigningKey(contractAddress, body) {
|
|
1400
|
+
return this.req(
|
|
1401
|
+
"POST",
|
|
1402
|
+
`/v5/contracts/${encodeURIComponent(contractAddress)}/keys/revoke`,
|
|
1403
|
+
body
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
async pauseContract(contractAddress, body) {
|
|
1407
|
+
return this.req(
|
|
1408
|
+
"POST",
|
|
1409
|
+
`/v5/contracts/${encodeURIComponent(contractAddress)}/pause`,
|
|
1410
|
+
body
|
|
1411
|
+
);
|
|
1412
|
+
}
|
|
1413
|
+
async unpauseContract(contractAddress, body) {
|
|
1414
|
+
return this.req(
|
|
1415
|
+
"POST",
|
|
1416
|
+
`/v5/contracts/${encodeURIComponent(contractAddress)}/unpause`,
|
|
1417
|
+
body
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
async resolveToken() {
|
|
1421
|
+
if (this.adminTokenProvider) return this.adminTokenProvider();
|
|
1422
|
+
return this.adminToken;
|
|
1423
|
+
}
|
|
1424
|
+
async req(method, path, body) {
|
|
1425
|
+
const token = await this.resolveToken();
|
|
1426
|
+
const controller = new AbortController();
|
|
1427
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
1428
|
+
try {
|
|
1429
|
+
const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
1430
|
+
method,
|
|
1431
|
+
headers: {
|
|
1432
|
+
accept: "application/json",
|
|
1433
|
+
"content-type": "application/json",
|
|
1434
|
+
authorization: `Bearer ${token}`
|
|
1435
|
+
},
|
|
1436
|
+
body: JSON.stringify(body),
|
|
1437
|
+
signal: controller.signal
|
|
1438
|
+
});
|
|
1439
|
+
const text = await response.text();
|
|
1440
|
+
const parsed = text ? safeParse(text) : void 0;
|
|
1441
|
+
if (!response.ok) {
|
|
1442
|
+
throw new WitniumchainApiError({
|
|
1443
|
+
status: response.status,
|
|
1444
|
+
message: parsed?.message ?? `${method} ${path} failed: ${response.status}`,
|
|
1445
|
+
body: parsed
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
return parsed;
|
|
1449
|
+
} finally {
|
|
1450
|
+
clearTimeout(timer);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
function safeParse(text) {
|
|
1455
|
+
try {
|
|
1456
|
+
return JSON.parse(text);
|
|
1457
|
+
} catch {
|
|
1458
|
+
return text;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1349
1462
|
// src/org-client.ts
|
|
1350
1463
|
var WitniumchainOrgClient = class {
|
|
1351
1464
|
inner;
|
|
@@ -1403,6 +1516,7 @@ exports.SigningKeys = SigningKeys;
|
|
|
1403
1516
|
exports.Subscriptions = Subscriptions;
|
|
1404
1517
|
exports.WitniumchainAdminClient = WitniumchainAdminClient;
|
|
1405
1518
|
exports.WitniumchainApiError = WitniumchainApiError;
|
|
1519
|
+
exports.WitniumchainChainAdminClient = WitniumchainChainAdminClient;
|
|
1406
1520
|
exports.WitniumchainClient = WitniumchainClient;
|
|
1407
1521
|
exports.WitniumchainOrgClient = WitniumchainOrgClient;
|
|
1408
1522
|
exports.defaultVerifierStorage = defaultVerifierStorage;
|