Skip to content

Commit

Permalink
feat: rename machineUserId to tokenId (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrazhnyk authored Apr 3, 2024
1 parent fe99f1e commit 56cd812
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion clients/typescript/client-cwe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { AuthProvider } from '@affinidi/test-auth-provider';
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/client-iam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { AuthProvider } from '@affinidi/test-auth-provider';
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/client-kms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { AuthProvider } from '@affinidi/test-auth-provider';
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/client-kyc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { AuthProvider } from '@affinidi/test-auth-provider';
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/client-ver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { AuthProvider } from '@affinidi/test-auth-provider';
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
2 changes: 1 addition & 1 deletion clients/typescript/client-vpa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { AuthProvider } from '@affinidi/test-auth-provider';
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/python/auth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'publicKey': '<your_public_key>',
'passphrase': 'top-secret',
'keyId': 'KeyId',
'machineUserId': '<your_machine_user_id>',
'tokenId': '<your_personal_access_token_id>',
'projectId': '<your_project_id>',
'tokenEndpoint': 'https://apse1.auth.developer.affinidi.io/auth/oauth2/token',
'apiGatewayUrl': 'https://apse1.api.affinidi.io'
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/python/client-cwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'publicKey': '<your_public_key>',
'passphrase': 'top-secret',
'keyId': 'KeyId',
'machineUserId': '<your_machine_user_id>',
'tokenId': '<your_personal_access_token_id>',
'projectId': '<your_project_id>',
'tokenEndpoint': 'https://apse1.auth.developer.affinidi.io/auth/oauth2/token',
'apiGatewayUrl': 'https://apse1.api.affinidi.io'
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/typescript/auth_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const authProvider = new AuthProvider({
publicKey: '<your_public_key>',
passphrase: 'top-secret',
keyId: 'KeyId',
machineUserId: '<your_machine_user_id>',
tokenId: '<your_personal_access_token_id>',
projectId: '<your_project_id>',
tokenEndpoint:
'https://apse1.auth.developer.affinidi.io/auth/oauth2/token',
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/typescript/client-cwe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const privateKey = '<your_private_key>'
const publicKey = '<your_public_key>'
const passphrase = 'top-secret'
const keyId = 'KeyId'
const machineUserId = '<your_machine_user_id>'
const tokenId = '<your_personal_access_token_id>'
const projectId = '<your_project_id>'
const tokenEndpoint =
'https://apse1.auth.developer.affinidi.io/auth/oauth2/token'
Expand All @@ -18,7 +18,7 @@ const apiGatewayUrl = 'https://apse1.api.affinidi.io'
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/typescript/client-iam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const privateKey = '<your_private_key>'
const publicKey = '<your_public_key>'
const passphrase = 'top-secret'
const keyId = 'KeyId'
const machineUserId = '<your_machine_user_id>'
const tokenId = '<your_personal_access_token_id>'
const projectId = '<your_project_id>'
const tokenEndpoint = 'https://apse1.auth.developer.affinidi.io/auth/oauth2/token'
const apiGatewayUrl = 'https://apse1.api.affinidi.io'
Expand All @@ -19,7 +19,7 @@ const projectScopedToken = '<your_project_id>'
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand All @@ -35,7 +35,7 @@ const iamConfiguration = new IamConfiguration({
async function getPolicies() {
const api = new PoliciesApi(iamConfiguration)

const { data } = await api.getPolicies(machineUserId, 'token')
const { data } = await api.getPolicies(tokenId, 'token')

return data
}
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/typescript/client-vpa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const privateKey = '<your_private_key>'
const publicKey = '<your_public_key>'
const passphrase = 'top-secret'
const keyId = 'KeyId'
const machineUserId = '<your_machine_user_id>'
const tokenId = '<your_personal_access_token_id>'
const projectId = '<your_project_id>'
const tokenEndpoint = 'https://apse1.auth.developer.affinidi.io/auth/oauth2/token'
const apiGatewayUrl = 'https://apse1.api.affinidi.io'
Expand All @@ -21,7 +21,7 @@ const projectScopedToken = '<your_project_id>'
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { AuthProvider } from '@affinidi/tdk-auth-provider'
const authProvider = new AuthProvider({
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand All @@ -47,7 +47,7 @@ import affinidi_tdk.auth_provider
stats = {
apiGatewayUrl,
keyId,
machineUserId,
tokenId,
passphrase,
privateKey,
publicKey,
Expand Down
10 changes: 5 additions & 5 deletions packages/auth-provider/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Jwt, ProjectScopedToken } from './helpers'
export interface IAuthProviderParams {
apiGatewayUrl: string
keyId: string
machineUserId: string
tokenId: string
passphrase: string
privateKey: string
projectId: string
Expand All @@ -15,7 +15,7 @@ export class AuthProvider {
private projectScopedToken = ''
private readonly apiGatewayUrl: string = ''
private readonly keyId: string = ''
private readonly machineUserId: string = ''
private readonly tokenId: string = ''
private readonly passphrase: string = ''
private readonly privateKey: string = ''
private readonly projectId: string = ''
Expand All @@ -28,7 +28,7 @@ export class AuthProvider {
const authProviderParams: IAuthProviderParams = {
apiGatewayUrl: '',
keyId: '',
machineUserId: '',
tokenId: '',
passphrase: '',
privateKey: '',
projectId: '',
Expand All @@ -38,7 +38,7 @@ export class AuthProvider {
this.validateMissingInput(authProviderParams, param)
this.apiGatewayUrl = param.apiGatewayUrl
this.keyId = param.keyId
this.machineUserId = param.machineUserId
this.tokenId = param.tokenId
this.passphrase = param.passphrase
this.privateKey = param.privateKey
this.projectId = param.projectId
Expand Down Expand Up @@ -73,7 +73,7 @@ export class AuthProvider {
await this.projectScopedTokenInstance.fetchProjectScopedToken({
apiGatewayUrl: this.apiGatewayUrl,
keyId: this.keyId,
machineUserId: this.machineUserId,
tokenId: this.tokenId,
passphrase: this.passphrase,
privateKey: this.privateKey,
projectId: this.projectId,
Expand Down
18 changes: 9 additions & 9 deletions packages/auth-provider/helpers/fetch-project-scoped-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as qs from 'qs'
const ALGORITHM = 'RS256'

export interface ISignPayload {
machineUserId: string
tokenId: string
tokenEndpoint: string
privateKey: string
passphrase: string
Expand All @@ -20,7 +20,7 @@ export interface IFetchProjectScopedToken extends ISignPayload {

export class ProjectScopedToken {
public async signPayload({
machineUserId,
tokenId,
tokenEndpoint,
privateKey,
passphrase,
Expand All @@ -29,8 +29,8 @@ export class ProjectScopedToken {
const issueTimeInSeconds = Math.floor(new Date().getTime() / 1000)

const payload = {
iss: machineUserId,
sub: machineUserId,
iss: tokenId,
sub: tokenId,
aud: tokenEndpoint,
jti: new Date().toString() + Math.random(),
exp: issueTimeInSeconds + 5 * 60,
Expand All @@ -53,14 +53,14 @@ export class ProjectScopedToken {
}

public async getUserAccessToken({
machineUserId,
tokenId,
tokenEndpoint,
privateKey,
passphrase,
keyId,
}: ISignPayload) {
const token = await this.signPayload({
machineUserId,
tokenId,
tokenEndpoint,
privateKey,
passphrase,
Expand All @@ -73,7 +73,7 @@ export class ProjectScopedToken {
client_assertion_type:
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
client_assertion: token,
client_id: machineUserId,
client_id: tokenId,
})

const { data } = await axios(tokenEndpoint, {
Expand All @@ -90,14 +90,14 @@ export class ProjectScopedToken {
public async fetchProjectScopedToken({
apiGatewayUrl,
projectId,
machineUserId,
tokenId,
tokenEndpoint,
privateKey,
passphrase,
keyId,
}: IFetchProjectScopedToken) {
const userAccessToken = await this.getUserAccessToken({
machineUserId,
tokenId,
tokenEndpoint,
privateKey,
passphrase,
Expand Down

0 comments on commit 56cd812

Please sign in to comment.