@oatscenter/trellis 0.100.0-rc.44 → 0.100.0-rc.46
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/auth/session_auth.js +37 -2
- package/internal_sdk/generated/apis/auth/mod.d.ts +13 -1
- package/internal_sdk/generated/apis/auth/mod.js +19 -5
- package/internal_sdk/generated/apis/core/mod.js +4 -4
- package/internal_sdk/generated/apis/events/mod.js +4 -4
- package/internal_sdk/generated/apis/health/mod.js +4 -4
- package/internal_sdk/generated/apis/jobs/mod.js +4 -4
- package/internal_sdk/generated/apis/state/mod.js +4 -4
- package/internal_sdk/generated/apps/cli/mod.d.ts +5 -0
- package/internal_sdk/generated/apps/cli/mod.js +6 -0
- package/internal_sdk/generated/apps/console/mod.d.ts +5 -0
- package/internal_sdk/generated/apps/console/mod.js +6 -0
- package/internal_sdk/generated/package.json +2 -2
- package/internal_sdk/generated/participants/eventsRuntime/mod.d.ts +1 -0
- package/internal_sdk/generated/participants/eventsRuntime/mod.js +5 -4
- package/internal_sdk/generated/participants/healthRuntime/mod.js +4 -4
- package/internal_sdk/generated/participants/jobsRuntime/mod.d.ts +1 -0
- package/internal_sdk/generated/participants/jobsRuntime/mod.js +5 -4
- package/internal_sdk/generated/participants/platform/mod.d.ts +2 -1
- package/internal_sdk/generated/participants/platform/mod.js +7 -6
- package/internal_sdk/generated/types/_internal/p0.d.ts +45 -2
- package/internal_sdk/generated/types/_internal/p0.js +27 -3
- package/internal_sdk/generated/types/index.d.ts +10 -0
- package/internal_sdk/generated/types/index.js +5 -0
- package/package.json +2 -2
- package/service/runtime/service.js +10 -4
package/auth/session_auth.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { nkeyAuthenticator } from "@nats-io/nats-core";
|
|
2
2
|
import { fromSeed, Prefix } from "@nats-io/nkeys";
|
|
3
|
-
import { Codec } from "@nats-io/nkeys/lib/codec.js";
|
|
4
3
|
import { trellisCrypto } from "./crypto.js";
|
|
5
4
|
import { createProof } from "./proof.js";
|
|
6
5
|
import { signAdmissionGetWasm, } from "./protocol_wasm.js";
|
|
@@ -11,7 +10,7 @@ export async function createAuth(opts) {
|
|
|
11
10
|
const seed = base64urlDecode(opts.sessionKeySeed);
|
|
12
11
|
const signer = await (await trellisCrypto()).signerFromSeed(seed);
|
|
13
12
|
const sessionKey = signer.publicKey;
|
|
14
|
-
const encodedSeed =
|
|
13
|
+
const encodedSeed = encodeNatsSeed(Prefix.User, seed);
|
|
15
14
|
const sessionNkey = fromSeed(encodedSeed).getPublicKey();
|
|
16
15
|
let serverClockOffsetMs = 0;
|
|
17
16
|
const resolveContextDigest = () => {
|
|
@@ -66,3 +65,39 @@ export async function createAuth(opts) {
|
|
|
66
65
|
},
|
|
67
66
|
};
|
|
68
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* A raw 32-byte Ed25519 seed as a NATS seed string (`SU…`), the form nkeys
|
|
70
|
+
* reads. nkeys does not export its encoder, so this follows its format: the
|
|
71
|
+
* seed prefix and key type in two bytes, the seed, a little-endian CRC-16
|
|
72
|
+
* (XMODEM) of those, all in unpadded RFC 4648 base32.
|
|
73
|
+
*/
|
|
74
|
+
function encodeNatsSeed(prefix, seed) {
|
|
75
|
+
const seedPrefix = 18 << 3;
|
|
76
|
+
const raw = new Uint8Array(2 + seed.length + 2);
|
|
77
|
+
raw[0] = seedPrefix | (prefix >> 5);
|
|
78
|
+
raw[1] = (prefix & 31) << 3;
|
|
79
|
+
raw.set(seed, 2);
|
|
80
|
+
let crc = 0;
|
|
81
|
+
for (const byte of raw.subarray(0, raw.length - 2)) {
|
|
82
|
+
crc ^= byte << 8;
|
|
83
|
+
for (let bit = 0; bit < 8; bit++)
|
|
84
|
+
crc = crc & 0x8000 ? ((crc << 1) ^ 0x1021) & 0xffff : (crc << 1) & 0xffff;
|
|
85
|
+
}
|
|
86
|
+
raw[raw.length - 2] = crc & 0xff;
|
|
87
|
+
raw[raw.length - 1] = crc >> 8;
|
|
88
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
89
|
+
let text = "";
|
|
90
|
+
let buffer = 0;
|
|
91
|
+
let bits = 0;
|
|
92
|
+
for (const byte of raw) {
|
|
93
|
+
buffer = (buffer << 8) | byte;
|
|
94
|
+
bits += 8;
|
|
95
|
+
while (bits >= 5) {
|
|
96
|
+
text += alphabet[(buffer >> (bits - 5)) & 31];
|
|
97
|
+
bits -= 5;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (bits > 0)
|
|
101
|
+
text += alphabet[(buffer << (5 - bits)) & 31];
|
|
102
|
+
return new TextEncoder().encode(text);
|
|
103
|
+
}
|
|
@@ -147,6 +147,8 @@ export type OIDCProvidersDeleteInput = Types0.AuthOIDCProviderMutationRequest;
|
|
|
147
147
|
export type OIDCProvidersDeleteOutput = Types0.AuthMutationResult;
|
|
148
148
|
export type OIDCProvidersDisableInput = Types0.AuthOIDCProviderMutationRequest;
|
|
149
149
|
export type OIDCProvidersDisableOutput = Types0.AuthMutationResult;
|
|
150
|
+
export type OIDCProvidersEnableInput = Types0.AuthOIDCProviderMutationRequest;
|
|
151
|
+
export type OIDCProvidersEnableOutput = Types0.AuthMutationResult;
|
|
150
152
|
export type OIDCProvidersGetInput = Types0.AuthOIDCProviderGetRequest;
|
|
151
153
|
export type OIDCProvidersGetOutput = Types0.AuthOIDCProviderGetResponse;
|
|
152
154
|
export type OIDCProvidersListInput = Types0.AuthPageRequest;
|
|
@@ -801,6 +803,16 @@ declare const __api: {
|
|
|
801
803
|
readonly download: false;
|
|
802
804
|
readonly pagination: undefined;
|
|
803
805
|
};
|
|
806
|
+
readonly "rpc:OIDCProviders.Enable": {
|
|
807
|
+
readonly kind: "rpc";
|
|
808
|
+
readonly descriptorName: "rpc:OIDCProviders.Enable";
|
|
809
|
+
readonly subject: "rpc.v1.auth.OIDCProviders.Enable";
|
|
810
|
+
readonly input: typeof Types0.AuthOIDCProviderMutationRequestCodec;
|
|
811
|
+
readonly output: typeof Types0.AuthMutationResultCodec;
|
|
812
|
+
readonly errors: readonly [typeof AuthError, typeof UnexpectedError, typeof ValidationError];
|
|
813
|
+
readonly download: false;
|
|
814
|
+
readonly pagination: undefined;
|
|
815
|
+
};
|
|
804
816
|
readonly "rpc:OIDCProviders.Get": {
|
|
805
817
|
readonly kind: "rpc";
|
|
806
818
|
readonly descriptorName: "rpc:OIDCProviders.Get";
|
|
@@ -1424,5 +1436,5 @@ declare const __api: {
|
|
|
1424
1436
|
readonly packageEvidence: unknown;
|
|
1425
1437
|
};
|
|
1426
1438
|
export declare const API: typeof __api;
|
|
1427
|
-
export declare const API_DIGEST: "-
|
|
1439
|
+
export declare const API_DIGEST: "BJDqs2lQlyBF5VFkxRLvI7IN8y-j79Oy00Em9y4sIIo";
|
|
1428
1440
|
export {};
|