Skip to content

Commit

Permalink
Merge pull request #73 from skyflowapi/SK-172
Browse files Browse the repository at this point in the history
SK-172/ Change context to "ctx" in CAA
  • Loading branch information
Shaik-Luqmaan authored Nov 24, 2022
2 parents b110c99 + 217c26a commit c47be41
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [1.7.1] - 2022-11-24

### Changed
- Rename context to 'ctx' in bearer token options.

## [1.7.0] - 2022-11-22

### Added
Expand Down
2 changes: 2 additions & 0 deletions samples/service-account/SignedTokenGenerationExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function getSignedTokenFromFilePath() {
return new Promise(async (resolve, reject) => {
try {
const options = {
ctx:'ctx',
dataTokens: ['dataToken1','dataToken2'],
};

Expand All @@ -34,6 +35,7 @@ function getSignedTokenFromCreds() {
return new Promise(async (resolve, reject) => {
try {
const options = {
ctx:'ctx',
dataTokens: ['dataToken1','dataToken2'],
};
let response = await generateSignedDataTokensFromCreds(
Expand Down
4 changes: 2 additions & 2 deletions samples/service-account/TokenGenerationWithContextExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getSkyflowBearerTokenWithContextFromFilePath() {
return new Promise(async (resolve, reject) => {
try {
const options = {
context: "context_id",
ctx: "context_id",
};
if (!isExpired(bearerToken)) resolve(bearerToken);
else {
Expand All @@ -37,7 +37,7 @@ function getSkyflowBearerTokenWithContextFromCreds() {
return new Promise(async (resolve, reject) => {
try {
const options = {
context: "context_id",
ctx: "context_id",
};
if (!isExpired(bearerToken)) resolve(bearerToken);
else {
Expand Down
8 changes: 4 additions & 4 deletions src/service-account/util/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export type ResponseSignedDataTokens = { token: string, signedToken: string }


export type BearerTokenOptions = {
context?: string,
ctx?: string,
roleIDs?: string[],
}

export type SignedDataTokensOptions = {
dataTokens: string[],
timeToLive?: number,
context?: string,
ctx?: string,
}

function generateBearerToken(credentialsFilePath, options?: BearerTokenOptions): Promise<ResponseToken> {
Expand Down Expand Up @@ -92,7 +92,7 @@ function getToken(credentials, options?: BearerTokenOptions): Promise<ResponseTo
aud: credentialsObj.tokenURI,
exp: expiryTime,
sub: credentialsObj.clientID,
...(options && options.context ? { ctx: options.context } : {}),
...(options && options.ctx ? { ctx: options.ctx } : {}),
};

if (claims.iss == null) {
Expand Down Expand Up @@ -313,7 +313,7 @@ function getSignedTokens(credentials, options: SignedDataTokensOptions): Promise
exp: expiryTime,
sub: credentialsObj.clientID,
tok: token,
...(options && options.context ? { ctx: options.context } : {}),
...(options && options.ctx ? { ctx: options.ctx } : {}),
};

if (claims.key == null) {
Expand Down

0 comments on commit c47be41

Please sign in to comment.