Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ export {
type ExternalJwtTokenProviderOptions,
} from './auth/token-providers.js';
export { attributeFQNsAsValues } from './policy/api.js';
export {
forEmail,
forClientId,
forUserName,
forToken,
withRequestToken,
} from './platform/authorization/entity-identifiers.js';
export * as EntityIdentifiers from './platform/authorization/entity-identifiers.js';
Comment thread
marythought marked this conversation as resolved.
/** @deprecated Use `EntityIdentifiers.forEmail()` instead. Will be removed in a future release. */
export { forEmail } from './platform/authorization/entity-identifiers.js';
/** @deprecated Use `EntityIdentifiers.forClientId()` instead. Will be removed in a future release. */
export { forClientId } from './platform/authorization/entity-identifiers.js';
/** @deprecated Use `EntityIdentifiers.forUserName()` instead. Will be removed in a future release. */
export { forUserName } from './platform/authorization/entity-identifiers.js';
/** @deprecated Use `EntityIdentifiers.forToken()` instead. Will be removed in a future release. */
export { forToken } from './platform/authorization/entity-identifiers.js';
/** @deprecated Use `EntityIdentifiers.withRequestToken()` instead. Will be removed in a future release. */
export { withRequestToken } from './platform/authorization/entity-identifiers.js';
export {
listAttributes,
validateAttributes,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/platform/authorization/entity-identifiers.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 6 additions & 12 deletions lib/tests/mocha/unit/entity-identifiers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { expect } from 'chai';
import {
forEmail,
forClientId,
forUserName,
forToken,
withRequestToken,
} from '../../../src/index.js';
import { EntityIdentifiers } from '../../../src/index.js';
import { Entity_Category } from '../../../src/platform/entity/entity_pb.js';
import type { EntityChain, Token } from '../../../src/platform/entity/entity_pb.js';
import type { BoolValue } from '@bufbuild/protobuf/wkt';
Expand All @@ -14,7 +8,7 @@ describe('EntityIdentifier helpers', () => {
describe('forEmail()', () => {
for (const email of ['user@example.com', '']) {
it(`builds an entityChain with emailAddress="${email}"`, () => {
const eid = forEmail(email);
const eid = EntityIdentifiers.forEmail(email);
expect(eid.identifier.case).to.equal('entityChain');
const chain = eid.identifier.value as EntityChain;
expect(chain.entities).to.have.lengthOf(1);
Expand All @@ -29,7 +23,7 @@ describe('EntityIdentifier helpers', () => {
describe('forClientId()', () => {
for (const clientId of ['my-client', '']) {
it(`builds an entityChain with clientId="${clientId}"`, () => {
const eid = forClientId(clientId);
const eid = EntityIdentifiers.forClientId(clientId);
expect(eid.identifier.case).to.equal('entityChain');
const chain = eid.identifier.value as EntityChain;
expect(chain.entities).to.have.lengthOf(1);
Expand All @@ -44,7 +38,7 @@ describe('EntityIdentifier helpers', () => {
describe('forUserName()', () => {
for (const userName of ['alice', '']) {
it(`builds an entityChain with userName="${userName}"`, () => {
const eid = forUserName(userName);
const eid = EntityIdentifiers.forUserName(userName);
expect(eid.identifier.case).to.equal('entityChain');
const chain = eid.identifier.value as EntityChain;
expect(chain.entities).to.have.lengthOf(1);
Expand All @@ -59,7 +53,7 @@ describe('EntityIdentifier helpers', () => {
describe('forToken()', () => {
for (const jwt of ['eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.test', '']) {
it(`builds a token identifier with jwt="${jwt.slice(0, 20)}..."`, () => {
const eid = forToken(jwt);
const eid = EntityIdentifiers.forToken(jwt);
expect(eid.identifier.case).to.equal('token');
expect((eid.identifier.value as Token).jwt).to.equal(jwt);
});
Expand All @@ -68,7 +62,7 @@ describe('EntityIdentifier helpers', () => {

describe('withRequestToken()', () => {
it('builds a withRequestToken identifier set to true', () => {
const eid = withRequestToken();
const eid = EntityIdentifiers.withRequestToken();
expect(eid.identifier.case).to.equal('withRequestToken');
expect((eid.identifier.value as BoolValue).value).to.equal(true);
});
Expand Down
Loading