@moon-x/node-sdk 0.2.0 → 0.4.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/dist/index.d.mts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.js +33 -0
- package/dist/index.mjs +35 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AccessTokenClaims, IdentityTokenClaims, PresenceTokenClaims, VerifiedSession } from '@moon-x/core/types';
|
|
2
2
|
export { AccessTokenClaims, BaseTokenClaims, IdentityTokenClaims, PresenceTokenClaims, VerifiedSession } from '@moon-x/core/types';
|
|
3
|
+
import { EphemeralSignerSignResult } from '@moon-x/core/sdk';
|
|
4
|
+
export { EphemeralSignerSignError, EphemeralSignerSignResult } from '@moon-x/core/sdk';
|
|
3
5
|
|
|
4
6
|
interface AuthOptions {
|
|
5
7
|
baseUrl: string;
|
|
@@ -100,6 +102,41 @@ interface MoonXClientConfig {
|
|
|
100
102
|
fetch?: typeof fetch;
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
interface EphemeralSignersConfig {
|
|
106
|
+
baseUrl: string;
|
|
107
|
+
/** MoonX publishable key — required for the Authorization header on /ephemeral-signers/* calls. */
|
|
108
|
+
publishableKey: string;
|
|
109
|
+
fetchImpl?: typeof fetch;
|
|
110
|
+
}
|
|
111
|
+
interface SignEphemeralSignerParams {
|
|
112
|
+
/** Lowercase-hex 32-byte Ed25519 signer public key, no 0x prefix. */
|
|
113
|
+
apiPubHex: string;
|
|
114
|
+
/** Lowercase-hex 32-byte Ed25519 signer private key, no 0x prefix. Never crosses the network. */
|
|
115
|
+
apiPrivHex: string;
|
|
116
|
+
/**
|
|
117
|
+
* Wallet UUID (from `user.wallets[i].id`) the agent should sign on
|
|
118
|
+
* behalf of. The SDK resolves this to the wallet's MPC `key_id` +
|
|
119
|
+
* stored `derivation_path` via /ephemeral-signers/me/wallets and
|
|
120
|
+
* caches the lookup per-process — integrators never see MPC or
|
|
121
|
+
* BIP-32 internals.
|
|
122
|
+
*/
|
|
123
|
+
walletId: string;
|
|
124
|
+
/** Lowercase-hex digest to sign. No 0x prefix. */
|
|
125
|
+
rawSigningPayloadHex: string;
|
|
126
|
+
/** Defaults to `now`. SES rejects timestamps further than ±5 min from its clock. */
|
|
127
|
+
issuedAt?: Date;
|
|
128
|
+
}
|
|
129
|
+
declare class EphemeralSigners {
|
|
130
|
+
private readonly cfg;
|
|
131
|
+
constructor(cfg: EphemeralSignersConfig);
|
|
132
|
+
/**
|
|
133
|
+
* Sign a digest on behalf of a previously-provisioned ephemeral signer.
|
|
134
|
+
* Returns the wallet's signature (NOT the Ed25519 sig over the body
|
|
135
|
+
* — that's an implementation detail consumed by SES internally).
|
|
136
|
+
*/
|
|
137
|
+
sign(params: SignEphemeralSignerParams): Promise<EphemeralSignerSignResult>;
|
|
138
|
+
}
|
|
139
|
+
|
|
103
140
|
/**
|
|
104
141
|
* MoonXClient is the entry point for the node SDK. Construct once per
|
|
105
142
|
* process and reuse across requests — the client holds in-memory caches
|
|
@@ -128,6 +165,7 @@ interface MoonXClientConfig {
|
|
|
128
165
|
*/
|
|
129
166
|
declare class MoonXClient {
|
|
130
167
|
readonly auth: Auth;
|
|
168
|
+
readonly ephemeralSigners: EphemeralSigners;
|
|
131
169
|
constructor(input: MoonXClientConfig);
|
|
132
170
|
}
|
|
133
171
|
|
|
@@ -170,4 +208,4 @@ declare class ConfigurationError extends MoonXError {
|
|
|
170
208
|
constructor(message: string);
|
|
171
209
|
}
|
|
172
210
|
|
|
173
|
-
export { AppResolutionError, AudienceMismatchError, ConfigurationError, ExpiredTokenError, InvalidTokenError, IssuerMismatchError, JwksFetchError, KidMismatchError, MalformedTokenError, MoonXClient, type MoonXClientConfig, MoonXError, type MoonXErrorCode, SubjectMismatchError, UnsupportedAlgorithmError };
|
|
211
|
+
export { AppResolutionError, AudienceMismatchError, ConfigurationError, EphemeralSigners, ExpiredTokenError, InvalidTokenError, IssuerMismatchError, JwksFetchError, KidMismatchError, MalformedTokenError, MoonXClient, type MoonXClientConfig, MoonXError, type MoonXErrorCode, type SignEphemeralSignerParams, SubjectMismatchError, UnsupportedAlgorithmError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AccessTokenClaims, IdentityTokenClaims, PresenceTokenClaims, VerifiedSession } from '@moon-x/core/types';
|
|
2
2
|
export { AccessTokenClaims, BaseTokenClaims, IdentityTokenClaims, PresenceTokenClaims, VerifiedSession } from '@moon-x/core/types';
|
|
3
|
+
import { EphemeralSignerSignResult } from '@moon-x/core/sdk';
|
|
4
|
+
export { EphemeralSignerSignError, EphemeralSignerSignResult } from '@moon-x/core/sdk';
|
|
3
5
|
|
|
4
6
|
interface AuthOptions {
|
|
5
7
|
baseUrl: string;
|
|
@@ -100,6 +102,41 @@ interface MoonXClientConfig {
|
|
|
100
102
|
fetch?: typeof fetch;
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
interface EphemeralSignersConfig {
|
|
106
|
+
baseUrl: string;
|
|
107
|
+
/** MoonX publishable key — required for the Authorization header on /ephemeral-signers/* calls. */
|
|
108
|
+
publishableKey: string;
|
|
109
|
+
fetchImpl?: typeof fetch;
|
|
110
|
+
}
|
|
111
|
+
interface SignEphemeralSignerParams {
|
|
112
|
+
/** Lowercase-hex 32-byte Ed25519 signer public key, no 0x prefix. */
|
|
113
|
+
apiPubHex: string;
|
|
114
|
+
/** Lowercase-hex 32-byte Ed25519 signer private key, no 0x prefix. Never crosses the network. */
|
|
115
|
+
apiPrivHex: string;
|
|
116
|
+
/**
|
|
117
|
+
* Wallet UUID (from `user.wallets[i].id`) the agent should sign on
|
|
118
|
+
* behalf of. The SDK resolves this to the wallet's MPC `key_id` +
|
|
119
|
+
* stored `derivation_path` via /ephemeral-signers/me/wallets and
|
|
120
|
+
* caches the lookup per-process — integrators never see MPC or
|
|
121
|
+
* BIP-32 internals.
|
|
122
|
+
*/
|
|
123
|
+
walletId: string;
|
|
124
|
+
/** Lowercase-hex digest to sign. No 0x prefix. */
|
|
125
|
+
rawSigningPayloadHex: string;
|
|
126
|
+
/** Defaults to `now`. SES rejects timestamps further than ±5 min from its clock. */
|
|
127
|
+
issuedAt?: Date;
|
|
128
|
+
}
|
|
129
|
+
declare class EphemeralSigners {
|
|
130
|
+
private readonly cfg;
|
|
131
|
+
constructor(cfg: EphemeralSignersConfig);
|
|
132
|
+
/**
|
|
133
|
+
* Sign a digest on behalf of a previously-provisioned ephemeral signer.
|
|
134
|
+
* Returns the wallet's signature (NOT the Ed25519 sig over the body
|
|
135
|
+
* — that's an implementation detail consumed by SES internally).
|
|
136
|
+
*/
|
|
137
|
+
sign(params: SignEphemeralSignerParams): Promise<EphemeralSignerSignResult>;
|
|
138
|
+
}
|
|
139
|
+
|
|
103
140
|
/**
|
|
104
141
|
* MoonXClient is the entry point for the node SDK. Construct once per
|
|
105
142
|
* process and reuse across requests — the client holds in-memory caches
|
|
@@ -128,6 +165,7 @@ interface MoonXClientConfig {
|
|
|
128
165
|
*/
|
|
129
166
|
declare class MoonXClient {
|
|
130
167
|
readonly auth: Auth;
|
|
168
|
+
readonly ephemeralSigners: EphemeralSigners;
|
|
131
169
|
constructor(input: MoonXClientConfig);
|
|
132
170
|
}
|
|
133
171
|
|
|
@@ -170,4 +208,4 @@ declare class ConfigurationError extends MoonXError {
|
|
|
170
208
|
constructor(message: string);
|
|
171
209
|
}
|
|
172
210
|
|
|
173
|
-
export { AppResolutionError, AudienceMismatchError, ConfigurationError, ExpiredTokenError, InvalidTokenError, IssuerMismatchError, JwksFetchError, KidMismatchError, MalformedTokenError, MoonXClient, type MoonXClientConfig, MoonXError, type MoonXErrorCode, SubjectMismatchError, UnsupportedAlgorithmError };
|
|
211
|
+
export { AppResolutionError, AudienceMismatchError, ConfigurationError, EphemeralSigners, ExpiredTokenError, InvalidTokenError, IssuerMismatchError, JwksFetchError, KidMismatchError, MalformedTokenError, MoonXClient, type MoonXClientConfig, MoonXError, type MoonXErrorCode, type SignEphemeralSignerParams, SubjectMismatchError, UnsupportedAlgorithmError };
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,8 @@ __export(src_exports, {
|
|
|
23
23
|
AppResolutionError: () => AppResolutionError,
|
|
24
24
|
AudienceMismatchError: () => AudienceMismatchError,
|
|
25
25
|
ConfigurationError: () => ConfigurationError,
|
|
26
|
+
EphemeralSignerSignError: () => import_sdk2.EphemeralSignerSignError,
|
|
27
|
+
EphemeralSigners: () => EphemeralSigners,
|
|
26
28
|
ExpiredTokenError: () => ExpiredTokenError,
|
|
27
29
|
InvalidTokenError: () => InvalidTokenError,
|
|
28
30
|
IssuerMismatchError: () => IssuerMismatchError,
|
|
@@ -500,6 +502,27 @@ function resolveConfig(input) {
|
|
|
500
502
|
};
|
|
501
503
|
}
|
|
502
504
|
|
|
505
|
+
// src/ephemeral-signers/index.ts
|
|
506
|
+
var import_sdk = require("@moon-x/core/sdk");
|
|
507
|
+
var EphemeralSigners = class {
|
|
508
|
+
constructor(cfg) {
|
|
509
|
+
this.cfg = cfg;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Sign a digest on behalf of a previously-provisioned ephemeral signer.
|
|
513
|
+
* Returns the wallet's signature (NOT the Ed25519 sig over the body
|
|
514
|
+
* — that's an implementation detail consumed by SES internally).
|
|
515
|
+
*/
|
|
516
|
+
async sign(params) {
|
|
517
|
+
return (0, import_sdk.signWithEphemeralSigner)({
|
|
518
|
+
...params,
|
|
519
|
+
baseUrl: this.cfg.baseUrl,
|
|
520
|
+
publishableKey: this.cfg.publishableKey,
|
|
521
|
+
fetchImpl: this.cfg.fetchImpl
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
|
|
503
526
|
// src/client.ts
|
|
504
527
|
var MoonXClient = class {
|
|
505
528
|
constructor(input) {
|
|
@@ -512,13 +535,23 @@ var MoonXClient = class {
|
|
|
512
535
|
appResolveTtlMs: cfg.appResolveTtlMs,
|
|
513
536
|
fetch: cfg.fetch
|
|
514
537
|
});
|
|
538
|
+
this.ephemeralSigners = new EphemeralSigners({
|
|
539
|
+
baseUrl: cfg.baseUrl,
|
|
540
|
+
publishableKey: cfg.publishableKey,
|
|
541
|
+
fetchImpl: cfg.fetch
|
|
542
|
+
});
|
|
515
543
|
}
|
|
516
544
|
};
|
|
545
|
+
|
|
546
|
+
// src/index.ts
|
|
547
|
+
var import_sdk2 = require("@moon-x/core/sdk");
|
|
517
548
|
// Annotate the CommonJS export names for ESM import in node:
|
|
518
549
|
0 && (module.exports = {
|
|
519
550
|
AppResolutionError,
|
|
520
551
|
AudienceMismatchError,
|
|
521
552
|
ConfigurationError,
|
|
553
|
+
EphemeralSignerSignError,
|
|
554
|
+
EphemeralSigners,
|
|
522
555
|
ExpiredTokenError,
|
|
523
556
|
InvalidTokenError,
|
|
524
557
|
IssuerMismatchError,
|
package/dist/index.mjs
CHANGED
|
@@ -462,6 +462,29 @@ function resolveConfig(input) {
|
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
// src/ephemeral-signers/index.ts
|
|
466
|
+
import {
|
|
467
|
+
signWithEphemeralSigner
|
|
468
|
+
} from "@moon-x/core/sdk";
|
|
469
|
+
var EphemeralSigners = class {
|
|
470
|
+
constructor(cfg) {
|
|
471
|
+
this.cfg = cfg;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Sign a digest on behalf of a previously-provisioned ephemeral signer.
|
|
475
|
+
* Returns the wallet's signature (NOT the Ed25519 sig over the body
|
|
476
|
+
* — that's an implementation detail consumed by SES internally).
|
|
477
|
+
*/
|
|
478
|
+
async sign(params) {
|
|
479
|
+
return signWithEphemeralSigner({
|
|
480
|
+
...params,
|
|
481
|
+
baseUrl: this.cfg.baseUrl,
|
|
482
|
+
publishableKey: this.cfg.publishableKey,
|
|
483
|
+
fetchImpl: this.cfg.fetchImpl
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
465
488
|
// src/client.ts
|
|
466
489
|
var MoonXClient = class {
|
|
467
490
|
constructor(input) {
|
|
@@ -474,12 +497,24 @@ var MoonXClient = class {
|
|
|
474
497
|
appResolveTtlMs: cfg.appResolveTtlMs,
|
|
475
498
|
fetch: cfg.fetch
|
|
476
499
|
});
|
|
500
|
+
this.ephemeralSigners = new EphemeralSigners({
|
|
501
|
+
baseUrl: cfg.baseUrl,
|
|
502
|
+
publishableKey: cfg.publishableKey,
|
|
503
|
+
fetchImpl: cfg.fetch
|
|
504
|
+
});
|
|
477
505
|
}
|
|
478
506
|
};
|
|
507
|
+
|
|
508
|
+
// src/index.ts
|
|
509
|
+
import {
|
|
510
|
+
EphemeralSignerSignError
|
|
511
|
+
} from "@moon-x/core/sdk";
|
|
479
512
|
export {
|
|
480
513
|
AppResolutionError,
|
|
481
514
|
AudienceMismatchError,
|
|
482
515
|
ConfigurationError,
|
|
516
|
+
EphemeralSignerSignError,
|
|
517
|
+
EphemeralSigners,
|
|
483
518
|
ExpiredTokenError,
|
|
484
519
|
InvalidTokenError,
|
|
485
520
|
IssuerMismatchError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/node-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MoonX server-side SDK for Node.js. Verify MoonX-issued access + identity tokens with zero runtime dependencies.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@moon-x/core": "0.
|
|
33
|
+
"@moon-x/core": "0.5.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"tsup": "8.5.1",
|