Initial import of verae-middleware from zapier monorepo

This commit is contained in:
George Lambert 2026-09-11 16:18:23 -04:00
commit 90713dcc78
70 changed files with 6773 additions and 0 deletions

View file

@ -0,0 +1,27 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { stableVeraeUserId } from '../../src/lib/identity.js';
import { issueTokenRef, resolveTokenRef } from '../../src/store/tokenRefs.js';
import { useTempStore } from '../helpers.js';
describe('verae identity', () => {
it('stableVeraeUserId is deterministic and not a JWT', () => {
const a = stableVeraeUserId('Ada@Example.com');
const b = stableVeraeUserId('ada@example.com');
assert.equal(a, b);
assert.match(a, /^vu_[0-9a-f]{16}$/);
assert.doesNotMatch(a, /eyJ/);
});
it('tokenRef resolves tenant and is not a Verae JWT', () => {
const ctx = useTempStore();
try {
const ref = issueTokenRef('tenant-1');
assert.match(ref, /^tref_/);
assert.equal(resolveTokenRef(ref), 'tenant-1');
assert.doesNotMatch(ref, /mock-jwt|eyJ/);
} finally {
ctx.cleanup();
}
});
});